Advertisement

menu

Started by April 30, 2002 05:01 AM
4 comments, last by edwinnie 22 years, 6 months ago
ok i finally got the menu working. i am using TOTWGPG, and the bob engine provided. but if i press the down key, the arrow "bob" did not disappear, although it did show at the position indicated by the down key. anyone who tried it b4, can help mi?
  
void Do_Menu(void)
{
//current menu states

if(arrow.y == 300)
{
	menu_state = MENU_STATE_NEWGAME;
}
else
if(arrow.y == 370)
{
	menu_state = MENU_STATE_EXIT;
}

//DirectInput

DInput_Read_Keyboard();

if (!keyboard_state[DIK_DOWN])
down = false;

if (!keyboard_state[DIK_UP])
up = false;

if (keyboard_state[DIK_DOWN] && !down)
{
    Set_Pos_BOB(&arrow, 150, 370);
	down = true;
}
else
if(keyboard_state[DIK_UP] && !up)
{
	Set_Pos_BOB(&arrow, 150, 300);
	up = true;  
}


if(menu_state == MENU_STATE_EXIT)
{
	// check of user is trying to exit

    if (keyboard_state[DIK_RETURN]) 
	{
    PostMessage(main_window_handle, WM_DESTROY,0,0);
    game_state = GAME_STATE_SHUTDOWN;
    } // end if

}
else
if(menu_state == MENU_STATE_NEWGAME)
{
     if(keyboard_state[DIK_RETURN])
	 {
	    game_state = GAME_STATE_RUN;
	    menu_state = MENU_STATE_OFF;
	 }
}

Draw_BOB16(&etris, lpddsback);
Draw_BOB16(&newgame, lpddsback);
Draw_BOB16(&exitgame, lpddsback);
Draw_BOB16(&arrow, lpddsback);


DDraw_Flip();
Wait_Clock(30);
} // end Do_menu

  
I don''t get what your asking.. It didn''t disappear, and it is at the position indicated by the down arrow? So, what is the problem? You don''t want it to move, and you want it (arrow) to vanish?
Advertisement
What is down initialized to, true or false? It looks like you may be saying here:

  if (keyboard_state[DIK_DOWN] && !down){    Set_Pos_BOB(&arrow, 150, 370);	down = true;}    


Pseudocode:
if (key is down and down != false )

In other words, if down = true, which it does not appear that you want.

That's what I am seeing as a potential problem from when you set it to false above. I may be off base, I have never read the book you're using.





[edited by - catfoodgood on April 30, 2002 2:32:31 PM]
this is wat i meant>

-> newgame
exit

the arrow object first appeared at newgame.
if i press "down" key, theoretically,
it should be something like this>

newgame
-> exit

but it turned out to be this>

-> newgame
-> exit

[edited by - edwinnie on April 30, 2002 8:33:39 PM]

[edited by - edwinnie on April 30, 2002 8:34:20 PM]
I guess you are clearing the screen then? (filling it w/ blackness)..

Are you drawing the ''arrow'' before you move it? What happens if you return the arrow to the ''new game'' menu selection?
i tried drawing the drawing the arrow after the movement,
but that i presume is quite impossible as well.

since movement will require a key to be pressed,
the draw function will execute 1st, even if it is lower than
the movement settings.

actualli, i saw this 1st>

-> newgame
exit

then after i press down>

it became this>

-> newgame
-> exit

if i press up, still this, but the "key" is actualli pointing
towards "newgame".

-> newgame
-> exit

This topic is closed to new replies.

Advertisement