Advertisement
zharry

ICS2O1-05 5/26/2016 Pygame Question 3 Answer

May 26th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.02 KB | None | 0 0
  1. import pygame
  2. from pygame.colordict import THECOLORS
  3.  
  4. pygame.init()
  5.  
  6. # Screen Size
  7. size = (700, 600)
  8. screen = pygame.display.set_mode(size)
  9.  
  10. # Window Caption
  11. pygame.display.set_caption("Squares")
  12.  
  13. # Background Color
  14. screen.fill(THECOLORS['ivory'])
  15.  
  16. # Rectangles
  17. pygame.draw.rect(screen, THECOLORS['cornflowerblue'], (0, 0, 100, 100))
  18. pygame.draw.rect(screen, THECOLORS['seagreen2'], (600, 0, 100, 100))
  19. pygame.draw.rect(screen, THECOLORS['orangered1'], (0, 500, 100, 100))
  20. pygame.draw.rect(screen, THECOLORS['darkorchid2'], (600, 500, 100, 100))
  21.  
  22. # Lines
  23. pygame.draw.line(screen, THECOLORS['maroon1'], (348, 0), (348, 600), 4)
  24. pygame.draw.line(screen, THECOLORS['deeppink1'], (0, 298), (700, 298), 4)
  25.  
  26. # Center Circle
  27. pygame.draw.circle(screen, THECOLORS['yellow1'],  (350, 300), 100)
  28.  
  29. # Game Loop
  30. pygame.display.flip()
  31. clock = pygame.time.Clock()
  32. keepGoing = True
  33. while keepGoing:
  34.     clock.tick(30)
  35.     for ev in pygame.event.get():
  36.         if ev.type == 12:
  37.             keepGoing = False
  38. pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement