Game reset
-
This seems like the kind of thing that may have been asked already, but I can't find any mention.
Is there a command for resetting your game? For example, when the player has died? -
@AndyG1985 No I'm afraid you have to do that yourself. Create a function called reset and set your variables back to the initial values.
-
Here's a pattern I often use;
loop if !game.active then show_splash() endIf initialise_variables() while game.active loop game_loop() repeat // If lives aren't zero then the game was quit prematurely. if game.lives == 0 then game_over() endIf repeat
If you bail out of
game_loop()
without settinggame.active
toFALSE
then it'll reinitialise a new "level" from scratch (or a brand new game if you don't loop aroundgame_loop()
). Obviously too, this allows for a "quit game" andgame_over()
call depending on how the game ends. -
Thanks a lot, I'll have a think about this for my game :)
-
@AndyG1985 Dave's sample program the ninja one is a good guide for this