[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] key pressed problem



Gabriele Farina wrote:
> when I run this script and I press one key, there are no problems; when
> I press a second key while I'm pressing the first one, the hero moves in
> the right direction. But when I release one of the two keys the hero
> stops...
> 
> why?

what about?

  while 1:
          #time.sleep(0.05)
          for e in pygame.event.get():
              if e.type == QUIT:
                  break
              elif e.type == KEYDOWN or e.type == KEYUP :
                  k = pygame.key.get_pressed()
                  chiave(hero,k)
              else:
                  hero.direction = -1


When you release a key, you have an event KEYUP. Just process it normally.

Guillaume

____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org