SETLOOPSUB question when mixing with PC code

Previous topic - Next topic

Kitty Hello

In GACK, I have a huuuuuge editor. I can't redesign that to use the loop-subs that are required for the HTML5 port.
But the game engine could well be ported. So I have 2 subs:
main_loop_sub and title_screen_sub.
When title presses a key, then main_loop_sub is set as the main sub and vice versa.
The "game" engine just starts at the title screen loop, and exits the main program routine. The game will loop the subs and it works.

Now! When I'm in the editor, I want to test the game. Thus, I need to call the title/main subs manually (I can't quit the "main" routine). How would I know which sub to trigger? Using a global variable? Isn't that silly?
Any better ideas?

spacefractal

Im only just use one loop for anything, and then use a main status variable to detect title, game and whatever im need. Thinks im have done that since early java....

Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

MrTAToad

Is it safe to continually change where SETLOOPSUB points to ?  If not, then a state machine would have to be used.

Slydog

I'm not exactly sure on what you're asking, but would the 'PROTOTYPE' command work?
Just set a variable (ex: 'currentSub') to point to either of the two routines, and change it when required.

If not, I like the state machine idea, nice and tidy.
You could even have state machine prototype variables pointing to three subs, depending on state: stateStart, stateExit, stateRunning, or something.  And the state machine would handle calling the proper 'stateRunning' routine each frame.
(The other two would be for initializing and finalizing states when they change.)
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Kitty Hello

Prototype is a nice ide. I fixed it by putting all into one big function now and then all into one big loop and then put that in a sub. It´s for GACK. ;)