Sign in to follow this  
0026sd

Games with menus

Recommended Posts

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

Share this post


Link to post
Share on other sites
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: [url="http://lspiroengine.com/?p=351"]http://lspiroengine.com/?p=351[/url] and [url="http://lspiroengine.com/?p=361"]http://lspiroengine.com/?p=361[/url]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this