[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[pygame] key pressed problem
I got this script to handle my events:
Def chiave(hero,key):
if key[K_DOWN]:
hero.set_directions(0,0,1)
elif key[K_UP]:
hero.set_directions(1,0,-1)
elif key[K_LEFT]:
hero.set_directions(2,-1,0)
elif key[K_RIGHT]:
hero.set_directions(3,1,0)
elif key[K_RETURN]:
if not hero.battle:
hero.battle = 1
....
while 1:
#time.sleep(0.05)
for e in pygame.event.get():
if e.type == QUIT:
break
elif e.type == KEYDOWN:
k = pygame.key.get_pressed()
chiave(hero,k)
else:
hero.direction = -1
....
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?
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org