Advertisement
Guest User

Untitled

a guest
May 29th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 KB | None | 0 0
  1. import pygame
  2. import time
  3. import random
  4. from Player import *
  5. from Obstacle import *
  6.  
  7. # Initialize Pygame
  8. pygame.init()
  9. game_over = False
  10.  
  11. # Color
  12. BLACK = (0, 0, 0)
  13. WHITE = (255, 255, 255)
  14. GRAY = (192, 192, 192)
  15.  
  16. # Setting up the window
  17. surfaceWidth = 800
  18. surfaceHeight = 500
  19.  
  20. surface = pygame.display.set_mode((surfaceWidth, surfaceHeight))
  21. pygame.display.set_caption("Rectangle Runner")
  22. clock = pygame.time.Clock()
  23.  
  24. #Player(surface, surface_height, surface_width, size, jump_height, color)
  25. obstacle = Obstacle(surface, surfaceWidth, surfaceHeight, 50, 100, BLACK)
  26. player = Player.Player(surface, surfaceHeight, surfaceWidth, 50, 300, BLACK, obstacle)
  27. # Game Loop
  28. while True:
  29.     for event in pygame.event.get():
  30.         if event.type == pygame.QUIT:
  31.             game_over = True
  32.         if event.type == pygame.KEYDOWN:
  33.             player.keyDown(event.key)
  34.         if event.type == pygame.KEYUP:
  35.             player.keyUp(event.key)
  36.         if game_over == True:
  37.             pygame.quit()
  38.             quit()
  39.  
  40.     surface.fill(GRAY)
  41.     player.getSize()
  42.  
  43.     player.checkBoundaries()
  44.     player.draw()
  45.     #Obstacle.draw()
  46.     obstacle.draw()
  47.     obstacle.checkBoundaries()
  48.     pygame.display.update()
  49.     clock.tick(60)
  50. # This code shall be unreachable
  51. pygame.quit()
  52. quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement