[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] confusing documentation



luke wrote:
for event in pygame.event.get():
   if event in [KEYDOWN,KEYUP]:

what's wrong with this?
(untested, you get the general idea i hope)
except having to indent everything more :-\

Nothing, I think, except that it's "event.type" in the second line. I do it something like this:


for event in pygame.event.get():
  if event.type == KEYDOWN:
    if event.key == K_k:
      print "Wow, you hit the K key!"
    elif event.key == K_j:
      pass
  elif event.type == MUSIC_STOPPED_EVENT:
    LoopMusic()
  elif event.type == QUIT:
    done = True

etc.

Kris