Page 1 of 1

Ignoring button?

Posted: Thu Sep 18, 2008 3:41 am
by sharondenscabbia
This piece of code is driving me mad. I'm trying to create a simple bat and ball game to get to grips with thie code. I am not a noob coder, but this is the first time i've tried coding for the wii. I'm using the latest devkitpro with the programmers notepad IDE and GRRLIB librarys.
This snippet of code brings up a continue screen, but i can't for the life of me get it to respond to WPAD_BUTTON_UP, DOWN or HOME. I have all relevent librarys included.

if (score == 0) // upon losing all lives
{
int boo = 1;
while (boo==1)
{
pressed = WPAD_ButtonsDown(0);
GRRLIB_FillScreen(rainbow);
GRRLIB_Printf(lossx, lossy, tex_font1, 0xffffffff, 2, "You Lose, HA! Continue? up=y, down=n");
if ( pressed & WPAD_BUTTON_UP ) //restart game if press up
{
score = 5;
boo = 0;
}
if (pressed & WPAD_BUTTON_DOWN) exit(0); //end game if press down
if ( pressed & WPAD_BUTTON_HOME ) exit(0);
GRRLIB_Render();
}
startGame();
boo=1;
}

Can anybody see any problems with this code? I sure can't...

Thanks,

Sharon

Re: Ignoring button?

Posted: Fri Sep 19, 2008 9:14 pm
by fizix610
Try this:

if (WPAD_ButtonsDown(0) && WPAD_BUTTON_DOWN) exit(0); //end game if press down

Re: Ignoring button?

Posted: Tue Sep 23, 2008 2:18 pm
by Eke
weird that nobody already answered correctly you on this one (obviously, the "fix" in the above post is wrong ) :|

check wiibrew for some advices on how to read the Wiimote

simply, you need to call WPAD_ScanPads to update the buttons status before checking them

Re: Ignoring button?

Posted: Wed Sep 24, 2008 2:04 am
by sharondenscabbia
Thankyou for your help. I'll try it tomorrow morning, and bring back the result.

Sharon