Re: miniSphere 4.6.0
Reply #1777 –
This is difficult to do in a general-purpose console module: To pause execution, the console has to run its own loop (not async friendly); and the modular nature of the Sphere v2 design means evaluating arbitrary JS code is of limited utility, as very little is actually reachable globally.
One of Sphere's biggest strengths, and why I fell in love with it in the first place, is that it allows you to code your game as though you were writing a DOS program. Those were the times when you could do all the polling, looping, etc. you want, in realtime, without having to worry about handling events from the operating system. You don't even need a central event pump because as long as you flip regularly, the engine takes care of all the OS-level event handling for you and your game stays responsive. It's of course possible to add an event system to the API, and I probably will need to do so sooner or later to pave the way for Oozaru, but I wouldn't want it to be the primary method of handling input.
You don't realize just how easy Sphere makes it for you--and this is something I didn't fully appreciate until I started working on miniSphere and had to actually implement it--until you notice that you can do this:
while (true) {
while (true) {
while (true) {
FlipScreen();
}
}
}
And when you close the window, Sphere will completely--and because JS is garbage collected, cleanly!--bail out of that for you. If an event system were enforced, you'd then have two options: 1) Limit yourself to a single, central event pump that watches for Quit events and bails out when it gets one (this is similar to what the built-in Dispatch loop does), or 2) Watch for Quit events in ALL of your loops and do the unwinding yourself. And if you forget to add a quit check in one of them, well, say hello to Task Manager.
Both of these approaches sharpen the learning curve significantly.