Advertisement
Ulabael

Код цикла фор

Feb 26th, 2023 (edited)
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. for i in events:
  2.         if i.type == pygame.KEYDOWN:
  3.             if i.key == pygame.K_LEFT:
  4.                 lr = "LEFT"
  5.             elif i.key == pygame.K_RIGHT:
  6.                 lr = "RIGHT"
  7.         if i.type == pygame.KEYUP:
  8.             if i.key == pygame.K_RIGHT and lr == 'RIGHT':
  9.                 lr = "STOP"
  10.             elif i.key == pygame.K_LEFT and lr == 'LEFT':
  11.                 lr = "STOP"
  12.  
  13. if lr == "LEFT":
  14.     х -= 3
  15. elif lr == "RIGHT":
  16.     х += 3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement