Wednesday, April 10, 2013

Ghost Train - Menus and Gamestates

Of course I jumped right in and started programming the action part of the game, cause really I had to get that instant gratification of seeing graphics on a screen with some input.  Having a bit of that (still much, much more to go), I need to go back and define the menus and the rest of the game.

Here are the different states of the game:

0.  Main splash screen.  Just a picture with "hit spacebar to continue".
1. Main menu.
2. Hire hunters.  This is going to be like a  bar or employment line.  You can see your available slots and build a team off of that.
3. Purchase items.  Special equipment for the team.  Buy, then give to a character.
4. Overall map.  This is where you see all of the train lines and select the one to work.  Train lines open as you get better.  Other optional idea is that instead of a map, you get a job posting screen and you select one of a few open jobs.  Either way, this state is where you select a route to work.
5. Action state.  This is the main game on the traincars.

There are probably some sub states in there like a screen before #4 and #5 that just says press start when ready.  I can always add those in later as I identify them.

Here's where my lack of programming background comes into play.  I'm not exactly sure how to create new callouts for the gamestates, so I have implemented them directly into the "update" and "draw" processes.  This seems to work fine, though is probably not the most practical method, especially if the program was large.

Right now, gamestate 0 is the main opening menu and gamestate 1 is the action part of the game.

protected override void Update(GameTime gameTime)

        {
            if (Gamestate == 0)
            {
              //Updates here...keyboard input.
                {
                    Gamestate = 1;
                }
            }
         

            if (Gamestate == 1)
            {
              //Updates here...keyboard input.
            }
            base.Update(gameTime);
        }

       protected override void Draw(GameTime gameTime)
        {
            if (Gamestate == 0)
            {
                //Draw something here.  Main Menu
            }
         
            if (Gamestate == 1)
            {
               //Draw something here.              
            } //
          }

I also saw from Microsoft's gamestate sample the use of the region marker and I'm using that to break each gamestate up so I can quickly find it.  This marker allows you to collapse code to make it easier to find.  Kind of like a bookmark.

#region gamestate0 draw
...
#endregion

Neat!  Now I have a main menu and you press spacebar to enter the next state.  Exciting stuff!

No comments:

Post a Comment