pygame.key.get_pressed[K_a], K_a is not defined!?
Patrick Mullen
saluk64007 at gmail.com
Fri May 2 13:36:58 EDT 2008
The K_a is a constant integer, but you don't need to worry about it's
value. It tells you the index in get_pressed() to check for. So:
print pygame.key.get_pressed()[pygame.K_a]
Says, look at the 97th index in the get_pressed() list and see if that is a
1 or a 0.
Or if you use the pygame events:
for evt in pygame.event.get():
if evt.type == pygame.KEYDOWN and evt.key == pygame.K_a:
print "a pressed"
evt.type and evt.key will both be integers that map to one of the type
constants and one of the key constants respectively. This way the key
constant works in both types of input handling (which are both useful for
different types of input).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080502/f04dd14d/attachment-0001.html>
More information about the Python-list
mailing list