Advertisement
OtsoSilver

Untitled

Oct 9th, 2021
772
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.72 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. font = pygame.font.SysFont("arial", 18)
  12.  
  13. x = SIZE[0] // 2
  14. y = SIZE[1] // 2
  15. R = 25
  16. herospeed = 10
  17. move = "NONE"
  18. gamemode = 1
  19. isGameRunning = True
  20. while isGameRunning:
  21.     if gamemode == 1:
  22.         for event in pygame.event.get():
  23.             if event.type == pygame.QUIT:
  24.                 isGameRunning = False
  25.        
  26.         text = font.render("Сложность: " + str(herospeed),1,BLACK)
  27.  
  28.         sc.fill(WHITE)
  29.         pygame.draw.rect(sc, (0,255,0), (170,100,160,50))
  30.         pygame.draw.rect(sc, (255,255,0), (170,200,160,50))
  31.         pygame.draw.rect(sc, (255,0,0), (170,300,160,50))
  32.    
  33.    
  34.     if gamemode  == 2:
  35.         for event in pygame.event.get():
  36.             if event.type == pygame.QUIT:
  37.                 isGameRunning = False
  38.             if event.type == pygame.KEYDOWN:
  39.                 if event.key == pygame.K_UP:
  40.                     move = "UP"
  41.                 if event.key == pygame.K_DOWN:
  42.                     move = "DOWN"
  43.                 if event.key == pygame.K_LEFT:
  44.                     move = "LEFT"
  45.                 if event.key == pygame.K_RIGHT:
  46.                     move = "RIGHT"
  47.             if event.type == pygame.KEYUP:
  48.                 move = "NONE"
  49.    
  50.         if move == "UP":
  51.             y -= herospeed
  52.         if move == "DOWN":
  53.             y += herospeed
  54.         if move == "RIGHT":
  55.             x += herospeed
  56.         if move == "LEFT":
  57.             x -= herospeed
  58.  
  59.         sc.fill(BLACK)
  60.         pygame.draw.circle(sc, WHITE, (x,y), R)
  61.  
  62.     pygame.display.update()
  63.  
  64.     clock.tick(FPS)
  65.  
  66. pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement