game programming



Still looking for hints how to implement this in gtk/gnome :
perfect would be a multi threaded setup, where one thread will do the
gtk stuff, and the other thread act as game engine.

passign data can be done with thread safe queue's, an easy task.
gtk -> game engine is simple : the callbacks put their data into the queue.
but back ? how can i inform the sleeping gtk thread to call some function ?

alternative: something like the "after" command from tcltk.
if you don't know tcl/tk, i have attached a part of the manpage.

currently i'm useing it for two thing :
a) i don't want to have the board items disappear here, and reappear there,
rather move over the board.
b) some board items have an animation (two pictures are swapped, and the
status is changed, so they act different).

any suggestion how i can build thing like this in c/gtk/gnome would be nice.
if the game engine has to delay a bit, the gtk main loop should keep on doing
it's job. i'm not very familiar with x11/gtk's internal stuff.

andreas
---
       This  command is used to delay execution of the program or
       to execute a command in background sometime in the future.
       It  has  several forms, depending on the first argument to
       the command:

       after ms
              Ms must be an integer giving a  time  in  millisec­
              onds.   The  command sleeps for ms milliseconds and
              then returns.  While the command  is  sleeping  the
              application does not respond to events.

       after ms ?script script script ...?
              In  this  form the command returns immediately, but
              it arranges for a Tcl command  to  be  executed  ms
              milliseconds  later  as an event handler.  The com­
              mand will be executed exactly once,  at  the  given
              time.  The delayed command is formed by concatenat­
              ing all the script arguments in the same fashion as
              the  concat  command.  The command will be executed
              at global level (outside the  context  of  any  Tcl
              procedure).  If an error occurs while executing the
              delayed command then the bgerror mechanism is  used
              to  report the error.  The after command returns an
              identifier that can be used to cancel  the  delayed
              command using after cancel.

       after cancel id
              Cancels the execution of a delayed command that was
              previously scheduled.  Id indicates  which  command
              should  be  canceled;  it must have been the return
              value from a previous after command.  If  the  com­
              mand given by id has already been executed then the
              after cancel command has no effect.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]