Advertisement
OtsoSilver

Untitled

Oct 9th, 2021
729
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 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 = 'menu'
  18. isGameRunning = True
  19. while isGameRunning:
  20.     if gamemode  == 'game':
  21.         for event in pygame.event.get():
  22.             if event.type == pygame.QUIT:
  23.                 isGameRunning = False
  24.             if event.type == pygame.KEYDOWN:
  25.                 if event.key == pygame.K_UP:
  26.                     move = "UP"
  27.                 if event.key == pygame.K_DOWN:
  28.                     move = "DOWN"
  29.                 if event.key == pygame.K_LEFT:
  30.                     move = "LEFT"
  31.                 if event.key == pygame.K_RIGHT:
  32.                     move = "RIGHT"
  33.             if event.type == pygame.KEYUP:
  34.                 move = "NONE"
  35.    
  36.         if move == "UP":
  37.             y -= herospeed
  38.         if move == "DOWN":
  39.             y += herospeed
  40.         if move == "RIGHT":
  41.             x += herospeed
  42.         if move == "LEFT":
  43.             x -= herospeed
  44.  
  45.         sc.fill(BLACK)
  46.         pygame.draw.circle(sc, WHITE, (x,y), R)
  47.     if gamemode == 'menu':
  48.        
  49.     pygame.display.update()
  50.  
  51.     clock.tick(FPS)
  52.  
  53. pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement