Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- import time
- import random
- from Player import *
- from Obstacle import *
- # Initialize Pygame
- pygame.init()
- game_over = False
- # Color
- BLACK = (0, 0, 0)
- WHITE = (255, 255, 255)
- GRAY = (192, 192, 192)
- # Setting up the window
- surfaceWidth = 800
- surfaceHeight = 500
- surface = pygame.display.set_mode((surfaceWidth, surfaceHeight))
- pygame.display.set_caption("Rectangle Runner")
- clock = pygame.time.Clock()
- #Player(surface, surface_height, surface_width, size, jump_height, color)
- obstacle = Obstacle(surface, surfaceWidth, surfaceHeight, 50, 100, BLACK)
- player = Player.Player(surface, surfaceHeight, surfaceWidth, 50, 300, BLACK, obstacle)
- # Game Loop
- while True:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- game_over = True
- if event.type == pygame.KEYDOWN:
- player.keyDown(event.key)
- if event.type == pygame.KEYUP:
- player.keyUp(event.key)
- if game_over == True:
- pygame.quit()
- quit()
- surface.fill(GRAY)
- player.getSize()
- player.checkBoundaries()
- player.draw()
- #Obstacle.draw()
- obstacle.draw()
- obstacle.checkBoundaries()
- pygame.display.update()
- clock.tick(60)
- # This code shall be unreachable
- pygame.quit()
- quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement