Re: Displaying intermediate button images.




Okay, I've read this web page and for the life of me, I can't see a
way to write a simple/elegant routine that does this, within the context of
my larger application.

Setup a event timer to call a function every 0.5 seconds.  Inside this function you
toggle all the pieces that will be effected by the current move.  The 4th time this
function is called, it will disable itself by disabling the event timer.

Inside your click callback event, you just enable the event timer.  You'll need to
keep the event ID somewhere you can easily get to it, but this shouldn't be much of
a problem.

void
reve_sleep(unsigned x)   /* Suspend execution for interval in microseconds. */
{
     struct timeval st_delay;

     while (gtk_events_pending()) {
         gtk_main_iteration();
     }

     st_delay.tv_usec = x;
     st_delay.tv_sec = 0;
     select(32, NULL, NULL, NULL, &st_delay);
}

This should also work, and has he somewhat good side effect of locking your UI so
the user can't issue additional commands until the "turn" is finished.  Depending on
how your game works, this may be good or bad.



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