[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pygame] Figuring out idle time
Robert Flemming wrote:
> 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.
this should be fairly simple. the part of your program that checks the
event queue should look something like this...
last_event_time = pygame.time.get_ticks()
screensaver_time = 60000 #60 seconds
no_screensaver = (MOUSEMOTION, MOUSEBUTTONDOWN, MOUSEBUTTONUP,
KEYDOWN, JOYAXISMOTION, JOYBUTTONDOWN,
JOYBALLMOTION, JOYHATMOTION, VIDEORESIZE, QUIT)
while 1:
for event in pygame.event.get():
if event in no_screensaver:
last_event_time = pygame.time.get_ticks()
handle_all_other_events_blah_blah(event)
if pygame.time.get_ticks() - last_event_time > screensaver_time:
do_the_screensaver()
rest_of_app()
def do_the_screensaver():
screen = pygame.display.get_surface()
original_screen = pygame.Surface(screen.get_size())
original_screen.blit(screen, (0,0))
while 1:
for event in pygame.event.get():
if event in no_screensaver:
screen.blit(original_screen, (0,0))
return
draw_pretty_graphics()
#should use one of korruptor's terrific effects in the PCR, like
#water, http://www.pygame.org/pcr/water/index.php
#motion blur, http://www.pygame.org/pcr/motion_blur/index.php
#acid, http://www.pygame.org/pcr/acidblur/index.php
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org