Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Acer722

How To Make a Game Menu? OpenGL

This topic is 6314 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have made a lot of 3d games/demos so far in OpenGL. My one question is how do I make a game menu for the games. If anybody has any place I could look where there is code for a game menu, or if you know how to do it, I would greatly appriciate it.

Share this post


Link to post
Share on other sites
Advertisement
I don''t have any code handy, but here''s how I did it (btw, it''s a little Object Oriented):

- the menu is just like your main loop, you scan for input, update logic, and draw, in a loop.

- have a CMenu class, which has a list of CMenuItems, each of which has position, graphics, and a pointer to a function to perform or menu to go to when clicked.

- have a CMenuManager class, which stores a list of menus, as well as a pointer to the current one. The list is so you don''t get any stray pointers, and so you can delete them all when you''re done.

In your game loop (pseudocode):

CMenuManager->get_input()
{
// check current menu: curr_menu->get_input()
// current menu checks mouse position, keyboard input, to see
// what button is being hovered over or atually clicked.
// If a button is clicked, you call the items[0]->whenclickedon() function
// or check the TargetMenu field to see if this button points to
// a new menu. If it points to a new menu, change the current_menu pointer
}


CMenuManager->Draw()
{
// draw background
// call curr_menu->Draw()
// CMenu::draw() loops through all the buttons. If the button
// state ( hover == true ) then draw the hover frame not the normal frame
// draw mouse pointer over the top
}

Well, hopefully that confused you a little more than you already are!

cheers,

freshya

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!