[Pythonmac-SIG] pygames event.get() ?
Wayne Folta
wfolta at netmail.to
Mon Feb 2 22:14:28 EST 2004
I just discovered pygames and it's a great module. One puzzler, though,
for anyone who is familiar with the package on MacOS X. (I'm assuming
the example works on the PC, though maybe it never worked as typed.)
The issue seems to be that pygame.event.get() is blocking. So the
little ball moving around the screen only moves when I move the cursor
around to feed it events. Any insight?
#!/usr/bin/env pythonw
import sys, pygame
pygame.init()
size = width, height = 320, 240
speed = [2, 2]
black = 0, 0, 0
screen = pygame.display.set_mode(size)
ball = pygame.image.load("ball.gif")
ballrect = ball.get_rect()
while 1:
for event in pygame.event.get(): # Here's the issue
if event.type == pygame.QUIT: sys.exit()
ballrect = ballrect.move(speed)
if ballrect.left < 0 or ballrect.right > width:
speed[0] = -speed[0]
if ballrect.top < 0 or ballrect.bottom > height:
speed[1] = -speed[1]
screen.fill(black)
screen.blit(ball, ballrect)
pygame.display.flip()
More information about the Pythonmac-SIG
mailing list