SDL input [solved]
Posted: Fri May 21, 2010 9:32 pm
I don't get what I'm doing wrong, I am attempting to make is so when I press the b key it only does the action once, right now it loops through a whole bunch of times.
Code: Select all
bool battle = false;
bkey = false
while(!done)
{
//key input
Uint8 *key = SDL_GetKeyState (NULL);
if (key[SDLK_b])
{
if (bkey == false)
{
bkey = true;
if(battle == true)
{
battle = false;
}
else if(battle == false)
{
battle = true;
}
}
else
{
bkey = false;
}
}