snowden_web

Untitled

Aug 8th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.17 KB | None | 0 0
  1. import pygame
  2.  
  3. # Define some colors
  4. BLACK = (0, 0, 0)
  5. WHITE = (255, 255, 255)
  6. GREEN = (0, 255, 0)
  7. RED = (255, 0, 0)
  8.  
  9. def drow_background(screen):
  10.     screen.fill(WHITE)
  11.  
  12. def drow_item(screen,x,y):
  13.     pygame.draw.rect(screen, GREEN, [0+x,0+y,30,10],0)
  14.     pygame.draw.circle(screen, BLACK, [15+x,5+y],7,0)
  15.  
  16. pygame.init()
  17.  
  18. # Set the width and height of the screen [width, height]
  19. size = (700, 500)
  20. screen = pygame.display.set_mode(size)
  21.  
  22. pygame.display.set_caption("My Game")
  23.  
  24. # Loop until the user clicks the close button.
  25. done = False
  26.  
  27. # Used to manage how fast the screen updates
  28. clock = pygame.time.Clock()
  29.  
  30. # Main Program Loop
  31. while not done:
  32.     # Main event loop
  33.     for event in pygame.event.get():
  34.         if event.type == pygame.QUIT:
  35.             done = True
  36.  
  37.     drow_background(screen)
  38.    
  39.     # get the current mouse position
  40.     pos = pygame.mouse.get_pos()
  41.    
  42.     x = pos[0]
  43.     y = pos[1]
  44.    
  45.     # drow item
  46.     drow_item(screen,x,y)
  47.  
  48.     # go ahead and update the screen with what we've drawn
  49.     pygame.display.flip()
  50.  
  51.     # limit to 60 frames per second
  52.     clock.tick(60)
  53.  
  54. # Close the window and quit
  55. pygame.quit()
Add Comment
Please, Sign In to add comment