Ура!
Код: Выделить всё
# Main game loop
def main_game():
running = True
while running:
global cross_x, cross_y
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
return
# Draw game screen
screen.blit(background, (0, 0))
# Crosshair movement
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_d:
cross_x = cross_x + 10
if event.key == pygame.K_a:
cross_x = cross_x - 10
if event.key == pygame.K_w:
cross_y = cross_y - 10
if event.key == pygame.K_s:
cross_y = cross_y + 10
screen.blit(crosshair, (cross_x, cross_y))
pygame.display.update()
clock.tick(60)
Подробнее здесь: https://stackoverflow.com/questions/792 ... g-the-keys
Мобильная версия