Check gamestate

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
jinxtengu
Posts: 122
Joined: Wed Oct 14, 2009 2:05 pm
Contact:

Check gamestate

Post by jinxtengu »

Hey, i just have a simple question, how would you write a condition to check the current gamestate.

would it be like?

return app.gamestate==levelone ;

Sorry is this seems really ignorant. Currently I've been assigning a variable to each gamestate, not a different variable just changing the number for one variable, and returning this number when i need to, but i realized that this probably isn't necessary.
Hope someone can help :)
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Re: Check gamestate

Post by Rado1 »

To implement different states of your game I would recommend to use AppState components - each representing a different state. Then, you probably will not need to check for the game state explicitly, because each AppState can make transition to other states knowing which state is active at the moment of transition. Of course you can have a special variable, e.g. GameState, and set/get its values explicitly:

Code: Select all

// declarations
const int
  TitleScreen = 0,
  LevelIntro = 1,
  Gameplay = 2,
  LevelFinished = 3;

int GameState;

// usage in code
GameState = TitleScreen;
...
if(Gameplay == LevelIntro) ...
but this is usually not necessary if you use AppState components.
Post Reply