best way to exit/quit a game?
BlitzMax Forums/BlitzMax Beginners Area/best way to exit/quit a game?
| ||
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? |
| ||
EndGraphics doesn't stop the program running, it just closes the graphics object. You should be using End. |
| ||
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. |
| ||
OnEnd? |
| ||
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. |
| ||
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 |
| ||
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. |
| ||
cheers guys - this is just what I was after :-) |