Skip to main content
gamedev.net
🔒 Locked

Simple Menu problem....

Started by s0lus May 29, 2003 at 10:03 AM 1 replies 950+ views
Original Post
s0lus
s0lus
ok, i am trying to make a simple menu...the user presses a number to access different sections of the menu...now the problem i am having is with my ''key'' presses...i have a section of code that when the enter key is pressed it is supposed to display the next part of the menu....but when i press the enter key it just flashes the next section...or if i hold it down it displays it...what would i need to do to have the enter key pressed once..and the next section of menu be displayed permenently...in a way....? thanks
CRACK123
CRACK123
Hey,

With menus you need to check Keydown and also the keyup processes. Also you don''t need speed or high performance input on menus so its perfectly alright not to use input API like Direct Input here. Lastly you need to use some kind of FSM so that nothing except menu is rendered while the game is in menu state and you would also need a lot of sub states for sub parts of the menu. Hope I answered your question.

Its not really an OpenGL question though. More of a game programming question.
The more applications I write, more I find out how less I know
PhiberOptic
PhiberOptic
Easy problem to solve.. take a look at this code.. (you could make it oop if you want.. )


  
#define MENU_MAIN 1
#define MENU_OPTIONS 2
#define MENU_NEWGAME 3
///////////////////

#define MENU_BACK 4

int current_menu = MENU_MAIN;
int current_selection = MENU_NEWGAME;

if( enter_pressed() )
{
switch( current_menu )
{
case MENU_MAIN:
switch( current_selection)
{
case MENU_NEWGAME:
current_menu = MENU_NEWGAME;
break;
}
break;
}

....

Render()
{
swtich( current_menu )
{
case MENU_MAIN:
DrawMainMenu();
break;
case MENU_NEWGAME:
DrawNewGameMenu();
break;
}
----------------------------------------------Petter Nordlander"There are only 10 kinds of people in the world. They who understand binary and those who do not"

Topic Locked

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

Sign in to reply to this topic.