Skip to main content
GameDev.net gamedev.net
🔒 Locked

Menu Systems

Started by aleks_1661 Nov 27, 2001 at 11:30 AM 4 replies 300+ views
Original Post
aleks_1661
aleks_1661
Just wondering ho people implement menu systems for their games? any hints. ive been trying to add a menu system but i dont know how to structure it within the program.
Twitter: [twitter]CaffinePwrdAl[/twitter] Website: (Closed for maintainance and god knows what else)
ATronic
ATronic
If your using a mouse, use picking. Elsewise do something like this.

enum menu{NewGame, LoadGame, Quit);
menu GameMenu=NewGame;

when moving up do this

if(GameMenu>0)
GameMenu--;
else
GameMenu=Quit;

Do the reverse for down, like so

if(GameMenu<2)
GameMenu++;
else
GameMenu=NewGame;

Then test to see what is selected and highlite it somehow in your game. You can also make other enumerations for sub-menues. That''s just one way.


Alex Broadwin
A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."
"The answer is out there."
"Please help, I''m using Windows!"
Alex BroadwinA-Tronic Software & Design-----"if you fail in life, you were destined to fail. If you suceed in life, call me.""The answer is out there.""Please help, I'm using Windows!"
Eber Kain
Eber Kain
the easiest thing i could think of for a menu is with the keyboard.

Just use the up and down keys to modify a variable that describes which button is highlighted, and then when enter or something is pressed react to that based on what key was selected via the variable. You will need to give the user something to show what button is highlighted, mabey draw an extra poly behind the ''button'' so that the selected on looks a bit larger.

Something like that should be simple to implement.
www.EberKain.comThere it is, Television, Look Listen Kneel Pray.
Maximus
Maximus
Make a graphical menu

Create a menu structure that holds the function of each menu item, a bounding box for each, etc.

When the mouse is clicked and the menu is active, check to see if the cursor is within the bounding box of any menu items... if so, perform its function.

The menu structure in my game is as so:

    
// Menu Type definitions

#define MT_BOOL 0

#define MT_SLIDER 1

#define MT_SUBMENU 2

#define MT_COMMAND 3

#define MT_SEPERATOR 4


typedef struct {
int bMin[2]; // min bounding coords

int bMax[2]; // max bounding coords


char text[32]; // text to display

char type; // type of item

float value; // value (for numerical items)

float speed,min,max;
bool boolval;
void *submenu;
void (*function)(void);
} menu_item_t;


typedef struct menu_s {
menu_item_t item[16]; // menu items (16 max)

unsigned char item_count; // number of menu items

unsigned char active; // index of active item

struct menu_s *next,*prev;
} menu_t;


It's not the most efficient, but it does the job quite well

Edited by - Maximus on November 29, 2001 1:47:37 AM
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
aleks_1661
aleks_1661
thanks guys, im alright on that side of things i just want to know how you incorperate a menu system into the program, do you use a class, a seperate set of draw, keyboard and mouse functions? ive been experimenting with different set of functions but it got real messy.

Twitter: [twitter]CaffinePwrdAl[/twitter] Website: (Closed for maintainance and god knows what else)
Eber Kain
Eber Kain
When i tackle a big project i give everything a seperate module.

EX....
GUI - object that takes care of drawing buttons and pics
MENU - module that contains the menu arrangement drawing routines
CHAR - Charcter data object
CHARCREATE - Charcter creation routines
GAMEPLAY - gameplay/rendering pipeline
LOAD - Object that handles all font/texture/data loading

Then from my main file i call respective display/mouse/keyboard/idle functions depending on what module is active so i can respond to events and keep each module on its own.
www.EberKain.comThere it is, Television, Look Listen Kneel Pray.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.