[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pygame] Figuring out idle time
On Sat, Sep 21, 2002 at 12:12:39PM -0700, Pete Shinners wrote:
> this should be fairly simple. the part of your program that checks the
> event queue should look something like this...
Excellent, this is more or less exactly what I was looking to do. Just
for the sake of clarity I think there were a few errors in the below
that I'll correct for everyone's benefit:
> 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:
I think you meant event.type and not just plain event.
> 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()
After the screensaver returns you should update last_event_time or else
it'll go right back into screensaver mode.
> 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:
Again I think you meant event.type
> 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
Terrific effects indeed.
Much thanks for the sample, this certainly pointed me in the right
direction (er, more like carried me down the road on your back :)
Thanks again.
Robert
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org