Hi.
I'm having an annoyance in my code. Such problem wasn't present in the previous version of my program.
Basically... Allegro has a volatile char key[MAX_KEYS] array that holds the state of each keyboard key, as 0 (released) or -1 (pressed). More info here.
In order to avoid a deadlock on checking keys, I usually do...
However, for some bizarre reason, the code doesn't work as it should do because my_key is ALWAYS zero.
I'm having an annoyance in my code. Such problem wasn't present in the previous version of my program.
Basically... Allegro has a volatile char key[MAX_KEYS] array that holds the state of each keyboard key, as 0 (released) or -1 (pressed). More info here.
In order to avoid a deadlock on checking keys, I usually do...
Code:
unsigned char value=0;
char my_key=0;
if( key[KEY_T] )
{
value |= 0x40;
if(0 == my_key) do_stuff(); //called only once! Avoids multiple calls while the key is pressed.
}
my_key = key[KEY_T];
char my_key=0;
if( key[KEY_T] )
{
value |= 0x40;
if(0 == my_key) do_stuff(); //called only once! Avoids multiple calls while the key is pressed.
}
my_key = key[KEY_T];
However, for some bizarre reason, the code doesn't work as it should do because my_key is ALWAYS zero.