Games with menus
Members - Reputation: 132
Posted 20 September 2012 - 12:03 PM
Just a general question. Are game menus (Start menu, pause menu, etc) typically put into their own class where all the drawing and logic would take place or are the menus all programmed in the main game logic class?
A lot of the tutorials and books I'm reading all have the start menu in the main game class however these are very simple menus (An image that says press enter to start game). I want to make complex menus with character stat selection and pause menus with options. Surely menus with so much logic wouldn't all be crammed into the main game class...?
Members - Reputation: 1162
Posted 20 September 2012 - 01:08 PM
A game state may be viewed as a specific game screen( a menu, a level, credits,...) and all game states communicate through the main game instance.
You might want to have a look at those articles that explains a general game engine architecture and game states management: http://lspiroengine.com/?p=351 and http://lspiroengine.com/?p=361
Members - Reputation: 493
Posted 20 September 2012 - 04:15 PM
I even wrote my own external menu loader that can load script files that are human-readable, or compiled for faster loading, and custom compiler.
Members - Reputation: 283
Posted 22 September 2012 - 02:33 PM
You can actually have hierarchial classes that manage game states and share some resources(e.g. drawing, animation, level, menu, AI), you can use enumerations, or even simple function/method calls for basic tasks, non-member.
I'd place a menu controller inside a class, and pass the necessary constructor to create the data for character stat selection, and call a drawing function to take it on from there.
Lastly, you can have a garbage collection member-class (if necessary) to deallocate all the used memory as well.