Unfortunately, no mouse available to the average user has that kind of
resolution and/or frame rate. What looks like “always” to a human is
"every now and then" to a computer, if even that.
(Your average CPU executes some 50 million instructions between each
event from a good, properly configured mouse. That’s 600000 printed
pages of asm code, or somewhere around 100000 printed pages of some
high level language.)
That said, to many applications, there is normally nothing to do if
there is no event to process, so you pretty much use the event
mechanism as the “time base” or driving force of the application. No
events, no cycles consumed. Simple, yet very effective.
Games, however, as opposed to “normal” GUI applications, almost
never work like this, so you’re better off basically forgetting all
about traditional GUI event handling when dealing with games. For
"action" games, you should preferably use the refresh rate (or the
best frame rate you can achieve) as your time base, rather than any
form of user input events. If smooth animation is less critical, or
minimal CPU usage is important, you can use some form of periodic
timer, which makes things more similar to, but still different from,
“normal” GUI programming. (Of course, any application that has
animations and stuff going on while waiting for user input is in a
gray zone.
//David Olofson - Programmer, Composer, Open Source Advocate
.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
— http://olofson.net — http://www.reologica.se —On Tuesday 25 January 2005 12.46, Roger D. Vargas wrote:
El mar, 25-01-2005 a las 14:47, Olof Bjarnason escribi?:
Think of the event queue like a QUEUE; if there are several
clients (events) waiting today (this time around the loop), you
may want to serve all of them today (this time around the loop)
and not tomorrow (next time around the loop), because otherwise
the queue will soon reach all over town (the event queue will
fill up). The while loop takes care of the events this time
around the loop, and the if takes “one customer per day”!
Well, my problem is i was considering this queue as infinite, I
mean, I thought there is ALWAYS an event in the queue, because
always the users is moving mouse, clicking or pressing keys.