Guest User

Untitled

a guest
Jan 22nd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. import pygame, sys, random
  2. from pygame.locals import *
  3.  
  4. def doRectsOverlap(rect1, rect2):
  5. for a, b in [(rect1, rect2), (rect2, rect1)]:
  6. if ((isPointInsideRect(a.left, a.top, b)) or
  7. (isPointInsideRect(a.left, a.bottom, b)) or
  8. (isPointInsideRect(a.right, a.top, b)) or
  9. (isPointInsideRect(a.right, a.bottom, b))):
  10. return True
  11. return False
  12.  
  13. def isPointInsideRect(x, y, rect):
  14. if (x > rect.left) and (x < rect.right) and (y > rect.top) and (y < rect.bottom):
  15. return True
  16. else:
  17. return False
  18.  
  19. # set up the colors
  20. BLACK = (0, 0, 0)
  21. GREEN = (0, 255, 0)
  22. WHITE = (255, 255, 255)
  23.  
  24. # set up pygame
  25. pygame.init()
  26. mainClock = pygame.time.Clock()
  27.  
  28. # set up the window
  29. WINDOWWIDTH = 800
  30. WINDOWHEIGHT = 600
  31. surface = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT), 0, 32)
  32. pygame.display.set_caption('Frogger')
  33.  
  34. playerPOS = [WINDOWWIDTH/2,WINDOWHEIGHT]
  35. playerSize = [50,50]
  36.  
  37.  
  38.  
  39. def draw():
  40. player()
  41. obstacle()
  42.  
  43. def player():
  44. pygame.draw.rect(surface, WHITE, (playerPOS[0]-(playerSize[0]/2), playerPOS[1]-(playerSize[1]), playerSize[0], playerSize[1]))
  45.  
  46. obstacles = []
  47. obstaclePOS = [WINDOWWIDTH/2,WINDOWHEIGHT]
  48. obstacleSize = [50,50]
  49. def obstacle(x,y):
  50. pygame.draw.rect(surface, GREEN, (x, y, obstacleSize[0], obstacleSize[1]))
  51.  
  52. def generate():
Add Comment
Please, Sign In to add comment