Advertisement
OtsoSilver

Untitled

Oct 9th, 2021
763
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.38 KB | None | 0 0
  1. import pygame
  2. pygame.init()
  3.  
  4. WHITE = (255,255,255)
  5. BLACK = (0,0,0)
  6. SIZE = (500,500)
  7. FPS = 60
  8.  
  9. sc = pygame.display.set_mode(SIZE)
  10. clock = pygame.time.Clock()
  11.  
  12. x = SIZE[0] // 2
  13. y = SIZE[1] // 2
  14. R = 25
  15. herospeed = 10
  16. move = "NONE"
  17. gamemode = 1
  18. b1=pygame.Rect(170,120,150,70)
  19. b2=pygame.Rect(170,210,150,70)
  20. b3=pygame.Rect(170,300,150,70)
  21. isGameRunning = True
  22. while isGameRunning:
  23.     if gamemode == 1:
  24.         pass
  25.     if gamemode == 2:
  26.         for event in pygame.event.get():
  27.             if event.type == pygame.QUIT:
  28.                 isGameRunning = False
  29.             if event.type == pygame.KEYDOWN:
  30.                 if event.key == pygame.K_UP:
  31.                     move = "UP"
  32.                 if event.key == pygame.K_DOWN:
  33.                     move = "DOWN"
  34.                 if event.key == pygame.K_LEFT:
  35.                     move = "LEFT"
  36.                 if event.key == pygame.K_RIGHT:
  37.                     move = "RIGHT"
  38.             if event.type == pygame.KEYUP:
  39.                 move = "NONE"
  40.    
  41.         if move == "UP":
  42.             y -= herospeed
  43.         if move == "DOWN":
  44.             y += herospeed
  45.         if move == "RIGHT":
  46.             x += herospeed
  47.         if move == "LEFT":
  48.             x -= herospeed
  49.    
  50.         sc.fill(BLACK)
  51.         pygame.draw.circle(sc, WHITE, (x,y), R)
  52.  
  53.     pygame.display.update()
  54.  
  55.     clock.tick(FPS)
  56.  
  57. pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement