best way to exit/quit a game?

BlitzMax Forums/BlitzMax Beginners Area/best way to exit/quit a game?

kaiserpc(Posted 2008) [#1]
Hi,

I've been trying to work out the best way to quit/exit from a game (did a search but couldn't find anything useful).

Anyway, my game can be exited from various functions/parts of my game and I'm currently just using endGraphics to quit out - I'm assuming there's a tidier way to do this?


GfK(Posted 2008) [#2]
EndGraphics doesn't stop the program running, it just closes the graphics object. You should be using End.


Gabriel(Posted 2008) [#3]
Er.. well Essentially

'Main Loop

Global GameOver=False

Repeat
   DoInput()
   Update()
   Render()
Until GameOver=True


Then GameOver is set to True whenever and wherever, and the game quits.

Of course, it's quite ugly doing it with a global, but I didn't want to complicate the answer by wrapping everything up into Types.


tonyg(Posted 2008) [#4]
OnEnd?


ImaginaryHuman(Posted 2008) [#5]
OnEnd just calls a function when the program ends or when you use the End command.

End is the command you want to totally stop the program.


MGE(Posted 2008) [#6]
At game end you should do something such as:

1) Release all objects. Yah I know GC does this, but I think it's good practice to properly release everything manually as well.
2) EndGraphics()
3) ShowMouse()
3) End


tonyg(Posted 2008) [#7]
OnEnd just calls a function when the program ends or when you use the End command.


OnEnd was a response to...
I'm assuming there's a tidier way to do this?


OnEnd is great as it allows all the general cleanup to be done in one function rather than spread throughout the program. It is much better to change one function than go hunting.


kaiserpc(Posted 2008) [#8]
cheers guys - this is just what I was after :-)