Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1075919 Posts in 44152 Topics- by 36120 Members - Latest Member: Royalhandstudios

December 29, 2014, 03:33:36 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Game states ( menu, game, highscore etc.) question
Pages: [1]
Print
Author Topic: Game states ( menu, game, highscore etc.) question  (Read 559 times)
njm1992
Level 0
**


Aaaaargh!


View Profile
« on: July 10, 2010, 12:08:34 AM »

I was wondering, how should I go about game states in game maker?

The reason I'm asking is because I have a little tetris clone and I want to make a menu, from where you can go to the game, the high-score list and exit the game.

I've considered having a room and a controller object for each game state, instead of having a variable in 1 controller object and using an If -> Else If -> Else to check the game state.

Any ideas or tips on how I should do this would be greatly appreciated Grin
Logged
Triplefox
Level 9
****



View Profile WWW Email
« Reply #1 on: July 10, 2010, 02:02:34 AM »

If you just want the simplest thing, do one room for the menu and one room for the game.

The menu options are objects with click events - this is the most flexible for GM since it lets them animate and react to input easily. If you want keyboard control the easiest thing is to maintain a counter variable for the selection cursor and use a separate if-then for the keyboard events - then move a cursor object to the position of the various option objects as the value changes. To do both keys and mouse is a little tricky but hardly impossible - you just have to decide how to reconcile mouse movements with the keyboard cursor(they could ignore each other, or the keyboard counter could change with mouse hover events). There isn't really any beautiful solution for menu UI, it just takes a lot of polish work.

For the game, I'm guessing that you just want a game flow of menu->game start->game over->menu. Just make the game room non-persistent and set all the game variables on entry - then GM's room transitions will do the rest for you.

If you want to be really fancy you might want an in-game menu. This requires being able to pause the gameplay at arbitrary moments, which is tricky since GM doesn't let you choose which things in the room have events. The best way I found to pause part of the game arbitrarily in GM, when I used it years ago, was to take a screenshot of the room, turn on persistence, go to a different room, draw the screenshot, and then run my menu/dialogue/etc. on top of the screenshot.
Logged

njm1992
Level 0
**


Aaaaargh!


View Profile
« Reply #2 on: July 10, 2010, 04:50:51 AM »

If you just want the simplest thing, do one room for the menu and one room for the game.

The menu options are objects with click events - this is the most flexible for GM since it lets them animate and react to input easily. If you want keyboard control the easiest thing is to maintain a counter variable for the selection cursor and use a separate if-then for the keyboard events - then move a cursor object to the position of the various option objects as the value changes. To do both keys and mouse is a little tricky but hardly impossible - you just have to decide how to reconcile mouse movements with the keyboard cursor(they could ignore each other, or the keyboard counter could change with mouse hover events). There isn't really any beautiful solution for menu UI, it just takes a lot of polish work.

For the game, I'm guessing that you just want a game flow of menu->game start->game over->menu. Just make the game room non-persistent and set all the game variables on entry - then GM's room transitions will do the rest for you.

If you want to be really fancy you might want an in-game menu. This requires being able to pause the gameplay at arbitrary moments, which is tricky since GM doesn't let you choose which things in the room have events. The best way I found to pause part of the game arbitrarily in GM, when I used it years ago, was to take a screenshot of the room, turn on persistence, go to a different room, draw the screenshot, and then run my menu/dialogue/etc. on top of the screenshot.


Thanks for the answer Smiley I've managed create my main menu and game over screens with 1 controller and 1 room per game "state".

Thanks for the help, Triplefox Hand Thumbs Up Left Grin Now I just gotta figure out writing a highscore list to a file with ds_list  Shrug
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic