Index: [thread] [date] [subject] [author]
  From: Andrew Apted <ajapted@netspace.net.au>
  To  : ggi-develop@eskimo.com
  Date: Sat, 24 Jul 1999 15:51:00 +1000

Re: GII problems and transparent blitter

Joel Stanley writes:

>  The keypress event works fine, in that each time there is a keypress the
>  ship turns as desired.  However, we want constant rotation when the key is
>  held down, and so we tried the emKeyRepeat event. This even works as
>  desired, until the key is released, and the result is that the ship keeps
>  spinning because there are so many emKeyRepeat events in the event queue.
> 
>  What we need is the ship to stop moving as soon as the key is
>  released...we'd like to be able to simply listen for the emKeyRelease
>  event and, when it is encountered, flush the queue of all queued
>  emKeyRepeat elements. However, I didn't see any documentation for
>  manipulation of the event queue and so I'm at odds with what to do.

There is a better way: 

When you get an evKeyPress event (e.g. for turn left), set a variable
that says "make the ship turn left" and then handle that variable in
your main loop, e.g. if (turnleft) TurnShipLeft().  When you get an
evKeyRelease event for that key, then clear that variable.

Not all targets have repeating keys, and on the ones that do, you can't
rely on either the repeat speed (which could be really slow) or the
delay before repeating.  So using evKeyRepeat the way you described is
not a good method for games.

Cheers,
___________________________________________________
                                               \  /
  Andrew Apted   <ajapted@netspace.net.au>      \/
 

Index: [thread] [date] [subject] [author]