Loading...
Logo
Processing Forum

Menu for a game

in General Discussion  •  Other  •  1 year ago  
I'm trying to create a game menu, so basically there's a start screen and your click the button to start the game...
how do I have different states of the screen, suppose game menu is a state, play game is another state, and then game over is another state, how do I go about implementing those in my game. Would I use a case statement, if someone could me some guidelines on how to do this then that would be great.

Thanks.


Replies(2)

Re: Menu for a game

1 year ago
I remember this being answered quite distinctly, but I can't find it...
Well, here's a general outline for a state-changing application:

Copy code
  1. int state = 0; //The current state
  2. final int MAIN_MENU = 0;
  3. final int GAME_MENU = 1;
  4. final int GAME = 2;
  5. final int PAUSE = 3;

  6. //Stuff

  7. void setup() {
  8.   size(600, 500);
  9.   
  10.   //Stuff
  11. }

  12. void draw() {
  13.   switch(state) {
  14.   case MAIN_MENU:
  15.     //Main Menu Stuff
  16.     break;
  17.   case GAME_MENU:
  18.     //Game Menu Stuff
  19.     break;
  20.   case GAME:
  21.     //Game Stuff
  22.     break;
  23.   case PAUSE:
  24.     //Pause Stuff
  25.     break;
  26.   }
  27. }

Re: Menu for a game

1 year ago
Thank you soooo much.