Index: [thread] [date] [subject] [author]
  From: Joel Stanley <jstanley@up.edu>
  To  : GGI Developers' Mailing List <ggi-develop@eskimo.com>
  Date: Fri, 23 Jul 1999 22:24:12 -0700 (PDT)

GII problems and transparent blitter

I've just starting using the GGI and GII libraries for the first time, so
please excuse the newbie-ishness of these questions.

First of all, I haven't had much luck finding in-depth example code for
libgii and so I'm wondering about the following:

A friend of mine and I are currently implementing a _very_ basic asteroids
clone under X and using ggi and gii exclusively.  We're having the
following problem in the main loop of our game:

<begin code snippet> 
for(;;) {
    struct timeval tv = { 0, 100 };
    
    if(ggiEventPoll(graphics->GetVisual(),
      gii_event_mask(emKeyRepeat|emKeyPress), &tv)) {
      ggi_event ev;
      ggiEventRead(graphics->GetVisual(), &ev,
      gii_event_mask(emKeyRepeat|emKeyPress));
      if(ev.key.type == evKeyRepeat || ev.key.type == evKeyPress) {
	switch(ev.key.sym) {
	case GIIUC_q: exit(0); break;
	case GIIUC_w: ((Ship*)ship)->MoveForward(); break;
	case GIIUC_a: ((Ship*)ship)->RotateLeft(); break;
	case GIIUC_d: ((Ship*)ship)->RotateRight(); break;
	}
      }
    }

    ... do all the graphics stuff here, etc
}
<end code snippet>

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.




Also, on a somewhat unrelated topic, I've heard that a transparent blitter
for GGI is currently nonexistent. Is anyone working on one, have plans to
work on one, or are we on our own and must implement one ourselves?

Thanks a ton,

Joel

--
Joel R. Stanley
jstanley@up.edu


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