Results 1 to 4 of 4
  1. #1
    tuve2's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Location
    Swe
    Posts
    396
    Reputation
    10
    Thanks
    22
    My Mood
    Drunk

    [TUT + Code] Game State

    If your going to make a game menu and and all those things and with that I mean all menus in the game including the game screen that show up. Everything in the game that show up is a part of a screen. (Just the way I show this way to code this)

    Add this code under the Game1 class:
    Code:
    private enum Screen
    {
    
    Menu, Lobby, Game
    }
    This is just a sample I did. And here are 3 different screens it is the Menu, Lobby and the Game.

    Now lets add what screen that it shall start showing.
    Code:
    Screen mCurrentScreen = Screen.Menu;
    Just add that code under the another one.

    Now it will just show the starting screen and we cant do anything.
    So lets add some controls to the game screens.

    Go down to Update.
    If you are going to make a computer game the add(if you haven't)
    Code:
    KeyboardState e = Keyboard.GetState();
    if your going to make it for xbox I wont go through the stuff in this tutorial.

    Now you have setup the basic on the controls. So lets set the controls.

    Add this code under the last code we added:
    Code:
    switch (mCurrentScreen)
    {
    
    case Screen.Menu: {
    if (e.IsKeyDown(Keys.Space) == true) {
    mCurrentScreen = Screen.Lobby;
    } break;
    } case Screen.Lobby: {
    break;
    } case Screen.Game: {
    break;
    }
    }
    Now when you press space when you start the game you go to the Lobby screen. I think you can figure out the rest. Or just ask.

    Now the last thing. Draw.

    Go down to Draw.
    and add the same code as in the update.
    Code:
    switch (mCurrentScreen)
    {
    case Screen.Menu: {
    break;
    } case Screen.Lobby: {
    break;
    } case Screen.Game: {
    break;
    }
    }
    And in those you past/write the code...

    I will make a video tutorial on this when I got time. Ask for help if you need. And yes Google isn't that helpful, on this.

    // Tuve2
    Last edited by tuve2; 10-29-2010 at 05:07 PM.

  2. #2
    'Bruno's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Portugal
    Posts
    2,883
    Reputation
    290
    Thanks
    1,036
    My Mood
    Busy
    Lmao.. This is poor.. seriously.

    Is this a case tutorial? or..? you really didn't explain anything special.. and There is really good tutorials about GameState at XNACreators.. :\
    Light travels faster than sound. That's why most people seem bright until you hear them speak.

  3. The Following User Says Thank You to 'Bruno For This Useful Post:

    Void (10-29-2010)

  4. #3
    tuve2's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Location
    Swe
    Posts
    396
    Reputation
    10
    Thanks
    22
    My Mood
    Drunk
    Quote Originally Posted by Brinuz View Post
    Lmao.. This is poor.. seriously.

    Is this a case tutorial? or..? you really didn't explain anything special.. and There is really good tutorials about GameState at XNACreators.. :\
    Well why don't you make any tutorials then?

  5. #4
    'Bruno's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Portugal
    Posts
    2,883
    Reputation
    290
    Thanks
    1,036
    My Mood
    Busy
    Quote Originally Posted by tuve2 View Post
    Well why don't you make any tutorials then?
    Obvious reason is obvious..

    So i won't get a bad comment like you did
    Light travels faster than sound. That's why most people seem bright until you hear them speak.

  6. The Following User Says Thank You to 'Bruno For This Useful Post:

    ♪~ ᕕ(ᐛ)ᕗ (11-18-2010)

Similar Threads

  1. QR Code Game.
    By Fogest in forum General
    Replies: 25
    Last Post: 06-22-2011, 03:39 PM
  2. [Tutorial] [Cross Fire Technical Tut] Best gaming Performance,internet,Lagging Fixes and more !
    By Harmony♫ in forum CrossFire Tutorials
    Replies: 29
    Last Post: 04-19-2011, 03:32 PM
  3. TUT Oneline Games Codes
    By [G]a[M]e[R] in forum C++/C Programming
    Replies: 12
    Last Post: 03-23-2011, 05:33 PM
  4. [Vid tut] Basic Game Hacking
    By Matrix_NEO006 in forum Programming Tutorials
    Replies: 5
    Last Post: 01-02-2010, 10:43 AM
  5. Replies: 37
    Last Post: 06-20-2006, 04:24 PM