Allegro: Why wait for an event or until 60 milliseconds is up?

Up vote 0 down vote favorite share g+ share fb share tw.

On the allegro wiki(wiki.allegro.cc/index.php?title=Allegro_...) it shows this code. Bool get_event = al_wait_for_event_until(event_queue, &ev, &timeout); I get what the code does but why wait for an event or until 60 milliseconds is up? WHy not just one or the other?

C++ timer allegro link|improve this question asked Feb 28 at 23:45user701329254 75% accept rate.

The tutorial is trying to be simple by not introducing timers. The timeout is just used in place of a timer ticking at 60fps. It needs to break out to draw the window, since it might be invalidated by the user if it is dragged off screen, minimized, etc. – Matthew Feb 29 at 17:43.

Some events are more or less guaranteed to happen; them not happening means that bad things are going on. Not getting the v-sync event means that the display no longer exists. Or something.

Not getting a timer event means that the Allegro timer system is broken (or someone set the timer to a really long duration). But some events may not happen at all. The timeout is there in case the event is never fired.

That way, you can detect it (via the return value) and do something about it. What so bad about just waiting forever until an event comes? Because a program needs to be responsive.

Presumably you're using the Allegro Game Programming library to make a game. Do you really want your game to stop for 2 minutes because of some event? Do you want your display to sit frozen on an image for 5 minutes, with the user not knowing what's going on?

Or do you want to be able to pop up a dialog box saying, " I'm waiting for something. Hold on a bit. " And then display an animated wait cursor.

Waiting forever is never a good idea.

If you waited for an event, that could be forever.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions