Advertisement
otorp2

basic pygame

Jan 23rd, 2016
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. import pygame
  2.  
  3. # initialize game engine
  4. pygame.init()
  5. # set screen width/height and caption
  6. size = [640, 480]
  7. screen = pygame.display.set_mode(size)
  8. pygame.display.set_caption('My Game')
  9. # initialize clock. used later in the loop.
  10. clock = pygame.time.Clock()
  11.  
  12. # Loop until the user clicks close button
  13. done = False
  14. while done == False:
  15. # write event handlers here
  16. for event in pygame.event.get():
  17. if event.type == pygame.QUIT:
  18. done = True
  19. # write game logic here
  20.  
  21. # clear the screen before drawing
  22. screen.fill((255, 255, 255))
  23. # write draw code here
  24.  
  25. # display what’s drawn. this might change.
  26. pygame.display.update()
  27. # run at 20 fps
  28. clock.tick(20)
  29.  
  30. # close the window and quit
  31. pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement