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

Re: [pygame] Re:



My recommendation, do this every frame:

key = pygame.key.get_pressed()
for event in pygame.event.get():
    if event.type == pygame.QUIT or key[pygame.K_ESCAPE]:
        #quit the game
    if event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE:
        #fire
if key[pygame.K_LEFT]:
    #rotate left
if key[pygame.K_RIGHT]:
    #rotate right
if key[pygame.K_UP]:
    #move forwards
if key[pygame.K_DOWN]:
    #move backwards

Note that if you add the line "from pygame.locals import *" to the top of your file, you can rid yourself of those annoying "pygame." things...

Ian