Hi,
I'm making a game in C++ and Allegro 5 and I'm having trouble with waiting for event, I think.
What I want is for a bitmap to keep flashing/blinking until the key enter is pressed.
This is what I have right now
The flashing and finishing the while(blinks) loop are working just fine but only
separately... When I play it, the bitmap just blinks forever no matter what I press.
Try and restructure your event loop a bit :
pseudocode :
while (!quit) {
if (redraw) {
Draw(bitmap , al_map_rgba(alpha,alpha,alpha,alpha));
redraw = false;
}
do {
ALLEGRO_EVENT ev;
wait_for_event(q , &ev);
if (ev.type == ALLEGRO_EVENT_TIMER) {
redraw = true;
if (glow) {
alpha += 1;
if (alpha >= 255) {glow = false;}
}
else {
alpha -= 1;
if (alpha < 1) {glow = true;}
}
}
if (ev.type == ALLEGRO_EVENT_KEY_DOWN) {quit = true;}
} while (HaveEvents(q));
}
Thanks! But what function do you mean by HaveEvents? (I'm new to programming, sorry)
I think he means al_is_event_queue_empty.
I mentioned it was 'psuedo' code, not real code.
The actual function you want is al_is_event_queue_empty().
I get the pseudocode part, it just wasn't super intuitive, gee.
Thanks!
Okay. 
Something that should be pointed out is that logic should be kept separate from drawing as much as possible. By moving the alpha altering (logic) code out of the drawing section, you clean it up considerably.
Welcome to Allegro! Happy coding.