Ignoring button?

Post Reply
sharondenscabbia
Posts: 2
Joined: Thu Sep 18, 2008 3:34 am

Ignoring button?

Post by sharondenscabbia » Thu Sep 18, 2008 3:41 am

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

fizix610
Posts: 2
Joined: Fri Sep 19, 2008 9:08 pm

Re: Ignoring button?

Post by fizix610 » Fri Sep 19, 2008 9:14 pm

Try this:

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

Eke
Posts: 64
Joined: Sat Mar 01, 2008 11:01 am

Re: Ignoring button?

Post by Eke » Tue Sep 23, 2008 2:18 pm

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

sharondenscabbia
Posts: 2
Joined: Thu Sep 18, 2008 3:34 am

Re: Ignoring button?

Post by sharondenscabbia » Wed Sep 24, 2008 2:04 am

Thankyou for your help. I'll try it tomorrow morning, and bring back the result.

Sharon

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests