Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame, sys, random
- from pygame.locals import *
- def doRectsOverlap(rect1, rect2):
- for a, b in [(rect1, rect2), (rect2, rect1)]:
- if ((isPointInsideRect(a.left, a.top, b)) or
- (isPointInsideRect(a.left, a.bottom, b)) or
- (isPointInsideRect(a.right, a.top, b)) or
- (isPointInsideRect(a.right, a.bottom, b))):
- return True
- return False
- def isPointInsideRect(x, y, rect):
- if (x > rect.left) and (x < rect.right) and (y > rect.top) and (y < rect.bottom):
- return True
- else:
- return False
- # set up the colors
- BLACK = (0, 0, 0)
- GREEN = (0, 255, 0)
- WHITE = (255, 255, 255)
- # set up pygame
- pygame.init()
- mainClock = pygame.time.Clock()
- # set up the window
- WINDOWWIDTH = 800
- WINDOWHEIGHT = 600
- surface = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT), 0, 32)
- pygame.display.set_caption('Frogger')
- playerPOS = [WINDOWWIDTH/2,WINDOWHEIGHT]
- playerSize = [50,50]
- def draw():
- player()
- obstacle()
- def player():
- pygame.draw.rect(surface, WHITE, (playerPOS[0]-(playerSize[0]/2), playerPOS[1]-(playerSize[1]), playerSize[0], playerSize[1]))
- obstacles = []
- obstaclePOS = [WINDOWWIDTH/2,WINDOWHEIGHT]
- obstacleSize = [50,50]
- def obstacle(x,y):
- pygame.draw.rect(surface, GREEN, (x, y, obstacleSize[0], obstacleSize[1]))
- def generate():
Add Comment
Please, Sign In to add comment