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

Re: [pygame] Figuring out idle time



What I would try...

Every time you have input, update a variable with the current "time" (in SDL this is the number of ms since the game started).  

Then in your main loop, see if the current "time" - last input time >= 1000*# of seconds to wait.

If so, go to screensaver mode.

Hope this helps.  I am new to pygame, but have been using SDL for years now.  

Jesse Andrews
Tux Typing project leader -- Tux4Kids.org


-----Original Message-----
From: Robert Flemming <flemming@spiralout.net>
To: pygame-users@seul.org
Date: Fri, 20 Sep 2002 13:48:21 -0700
Subject: [pygame] Figuring out idle time

This is probably a remedial question, but I'm at kind of a loss as how
to do it right now.  I have an app in which I'd like to build in a
screensaver function.  After a given amount of idle time I'd like to
trigger the screensaver and exit it when an event is detected.  The
problem I'm having I believe is mostly related to the fact that I'm
using the event queue to check for key presses and thus I'm not sure how
to keep track of idle time in the main while loop.  The way I'm guessing
things would work would be to setup a timer of sorts (pygame.time ?),
then inside my main while loop have another while loop that checks for
either <= or >= to a configured interval and executes either the main
app function or the screensaver function depending upon that value.  In
the main app function I would then need to reset the timer value to 0
every time and input event is received.  The problem I seem to be
encountering is that when using the event queue the loop is only
completed when an event is received thus I can't monitor idle time.
This probably isn't difficult to solve, I'm just feeling especially
inept today :)  Any thoughts or snippets of code that might point me in
the right direction would be appreciated.  Thanks Much

Robert
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org



____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org