Advertisement
k1alo

Tree

Mar 15th, 2024
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.51 KB | None | 0 0
  1. import pygame
  2. from sys import exit
  3. from age import keys
  4.  
  5. pygame.init()
  6.  
  7. display = pygame.display.set_mode( (800, 600) )
  8. pygame.display.set_caption("MG1")
  9.  
  10. x1 = 100
  11. y1 = 100
  12. x2 = 100
  13. y2 = 130
  14. x3 = 100
  15. y3 = 160
  16. x4 = 100
  17. y4 = 70
  18. x5 = 130
  19. y5 = 100
  20. x6 = 70
  21. y6 = 100
  22. speed_y = 0
  23. speed_x = 0
  24. FPS = 60
  25. clock = pygame.time.Clock()
  26. while True:
  27.     speed_x = 0
  28.     speed_y = 0
  29.     keys = pygame.key.get_pressed()
  30.     for event in pygame.event.get():
  31.         if event.type == pygame.QUIT:
  32.             pygame.quit()
  33.             exit()
  34.         elif keys[pygame.K_s]:
  35.             speed_y += 10
  36.         elif keys[pygame.K_d]:
  37.             speed_x += 10
  38.         elif keys[pygame.K_a]:
  39.             speed_x -= 10
  40.         elif keys[pygame.K_w]:
  41.             speed_y -= 10
  42.  
  43.  
  44.  
  45.     x1 += speed_x
  46.     y1 += speed_y
  47.     x2 += speed_x
  48.     y2 += speed_y
  49.     x3 += speed_x
  50.     y3 += speed_y
  51.     x4 += speed_x
  52.     y4 += speed_y
  53.     x5 += speed_x
  54.     y5 += speed_y
  55.     x6 += speed_x
  56.     y6 += speed_y
  57.  
  58.     pygame.draw.rect(display, (139, 69, 19), pygame.Rect(x1, y1, 30, 30))
  59.     pygame.draw.rect(display, (139, 69, 19), pygame.Rect(x2, y2, 30, 30))
  60.     pygame.draw.rect(display, (139, 69, 19), pygame.Rect(x3, y3, 30, 30))
  61.     pygame.draw.rect(display, (0, 128, 0), pygame.Rect(x4, y4, 30, 30))
  62.     pygame.draw.rect(display, (0, 128, 0), pygame.Rect(x5, y5, 30, 30))
  63.     pygame.draw.rect(display, (0, 128, 0), pygame.Rect(x6, y6, 30, 30))
  64.     pygame.display.update()
  65.     display.fill((0, 0, 0))
  66.     clock.tick(FPS)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement