gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > sprite appearing problem

#8893 - Daikath - Wed Jul 23, 2003 11:51 am

I am making this game wich has a set of sprites on screen (10 in total) wich are 8x16 and blue. They are supposed to give an indication of how much time a person has left before it is too late.

The problem is with my getting it properly displayed. I have used a global s16 variable wich helps me getting the right number of sprites displayed. When I leave that variable alone I see another sprite animating as it should and the timer (one sprite for the timer for now) as it should.

But when I put in the keypad function

Code:

void keypad(void)
{
         if (KEYS & KEY_A)
         {
              timerfunc--;
         }
}


I only see the sprite for a second and then it is gone without me pressing a button.

The timerfunc variable is only used for this occasion.

Can someone tell me what is going wrong here?
_________________
?There are no stupid questions but there are a LOT of inquisitive idiots.?

#8894 - hnager - Wed Jul 23, 2003 12:02 pm

are you calling keypad in the main while loop? your keypad function is actually checking to see if A is not pressed - you have to check if the bit is cleared to see if A is pressed:

if(!(KEYS & KEY_A))
{
timerfunc--;
}

#8896 - Daikath - Wed Jul 23, 2003 12:34 pm

Lol, thanks :).
_________________
?There are no stupid questions but there are a LOT of inquisitive idiots.?