Game state management (Game, Menu, Titlescreen, etc)

Posted by munchor on Game Development See other posts from Game Development or by munchor
Published on 2012-08-25T10:09:38Z Indexed on 2012/11/22 23:11 UTC
Read the original article Hit count: 259

Filed under:
|
|

Basically, in every single game I've made so far, I always have a variable like "current_state", which can be "game", "titlescreen", "gameoverscreen", etc.

And then on my Update function I have a huge:

if current_state == "game" 
  game stuf
  ...
else if current_state == "titlescreen"
  ...

However, I don't feel like this is a professional/clean way of handling states. Any ideas on how to do this in a better way? Or is this the standard way?

© Game Development or respective owner

Related posts about lua

Related posts about structure