Advertisement
k1alo

Untitled

Mar 15th, 2024
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. import pygame
  2. from sys import exit
  3.  
  4. from age import keys
  5.  
  6. pygame.init()
  7.  
  8. display = pygame.display.set_mode( (800, 600) )
  9. pygame.display.set_caption("MG1")
  10.  
  11. x1 = 0
  12. y1 = 0
  13. speed_y = 0
  14. speed_x = 0
  15. FPS = 60
  16. clock = pygame.time.Clock()
  17. while True:
  18.     speed_x = 0
  19.     speed_y = 0
  20.     keys = pygame.key.get_pressed()
  21.     for event in pygame.event.get():
  22.         if event.type == pygame.QUIT:
  23.             pygame.quit()
  24.             exit()
  25.         elif keys[pygame.K_s]:
  26.             speed_y += 10
  27.         elif keys[pygame.K_d]:
  28.             speed_x += 10
  29.         elif keys[pygame.K_a]:
  30.             speed_x -= 10
  31.         elif keys[pygame.K_w]:
  32.             speed_y -= 10
  33.  
  34.  
  35.  
  36.     x1 += speed_x
  37.     y1 += speed_y
  38.     pygame.draw.rect(display, (0, 128, 255), pygame.Rect(x1, y1, 30, 30))
  39.     pygame.display.update()
  40.     display.fill((0, 0, 0))
  41.     clock.tick(FPS)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement