Hi everyone,
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...?
Thanks,
Scott
Games with menus
In my main game class, I use a StateMachine to manage game states transitions.
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
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
What I have for my engine are 2 states: "In Game" and "In Screen". Since it is a 3D game, I separated the game and screen drawing and logic. So if the user goes into the credits, the main menu, the pause menu, etc. it switches states. I also have an interface for "Screens" or "Menus" which helps for general or specific menus.
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.
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.
You should code in the parts of your game structure the way you see it best.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement