Advertisement
AyanUpadhaya

Pygame Lesson One | Random Balls

Oct 16th, 2021
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. #blue box
  2. import pygame
  3. import random
  4.  
  5. #variable
  6. run = True
  7. #init pygame
  8. pygame.init()
  9.  
  10. #screen
  11. screen = pygame.display.set_mode((800,600))
  12.  
  13. #title
  14. pygame.display.set_caption("Blue sky")
  15.  
  16. #game loop
  17. while run:
  18.     #handle event
  19.     for event in pygame.event.get():
  20.         if event.type == pygame.QUIT:
  21.             run = False
  22.             quit()
  23.  
  24.     #colo screen
  25.     screen.fill((135,206,235))
  26.  
  27.     #coordinates
  28.     x = random.randint(10,790)
  29.     y = random.randint(10,590)
  30.    
  31.     #radius
  32.     r = random.randint(2,18)
  33.  
  34.     #draw circle
  35.     pygame.draw.circle(screen, (0,0,150),(x,y),r)
  36.  
  37.     #update the screen
  38.     pygame.display.flip()
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement