I'm completely new to python (and it's been a while since I've coded much). I'm trying to call a method which acts as an event handler in a little "hello world" type game, but it's not working at all. I'm using the pygames 1.9.1 lib with python 2.6.1 on OSX 10.6.3.
So this is in a while loop:
self.exitCheck()
if self.controlUpdate == True:
self.playerX += 1
And the two methods in question are:
def exitCheck(self):
for event in pygame.event.get():
if event.type == KEYDOWN:
if event.key == pygame.K_ESCAPE:
print "Escape pressed"
pygame.quit()
exit()
def controlUpdate(self):
for event in pygame.event.get():
if event.type == KEYDOWN:
if event.key == pygame.K_SPACE:
print "Spacebar pressed"
return True
elif event.type == KEYUP:
if event.key == pygame.K_SPACE:
print "Spacebar not pressed"
return False
else:
return False
exitCheck is always, but controlUpdate never seems to get called while in the conditional. I feel like I've either missed something from the python book I've been going through (the oreilly Learning Python) or I've just taken too long a break from proper coding, but yeah. Would much appreciate the help.