Jump to content
  • Advertisement
Sign in to follow this  
zChrisse

State Variables Boolean versus Enum?

This topic is 4835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was thinking of creating variables like, boolean intro, boolean endgame and such to control where in the game i am. If im at the intro screen in the match etc... Is that a good way to go or isit totally wrong? Can use enum too :P Anyways here´s an example Example: (if enum is used) enum game_state {intro, choose_player, match, end_game};
while(true)
{
    switch(game_state)
    {
        case intro: code; break;
        case choose_player: code; break;
    }
}
Thanks for answer :) Cheers! // edit - gave the thread a title [Edited by - LessBread on August 25, 2005 3:23:35 PM]

Share this post


Link to post
Share on other sites
Advertisement
Go with the enumeration if you can only be in one game state at a time.

If you can be in multiple states at the same time, create a class with properties representing the various states.

Share this post


Link to post
Share on other sites
My personal favorite is by pushing classes (all inheriting a base class) onto a stack. You need to be aware of how many items are on the stack tho. Don't want to continuously add load game or save game onto the stack.

for example my game stack might look like this:
|*********|
|*********|
|*********|
|*Main Menu|
------------

|*********|
|*********|
|*game loop|
|*Main Menu|
------------

|************|
|*in game menu|
|*game loop***|
|*Main Menu**|
---------------

now if the user loads another game, i don't want to push another game loop instead pop everything up to the main menu. then push a game loop.


~guyaton

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!