Advertisement
pipsqueaker117

Board.py

Nov 7th, 2012
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.60 KB | None | 0 0
  1. #Board.py
  2. '''
  3. Created on Nov 6, 2012
  4.  
  5. @author: pipsqueaker
  6. '''
  7. import pygame, sys
  8. #import redSquare
  9. import physicsEngine
  10. import time
  11.  
  12. rectCalc = physicsEngine.rectangleDeity
  13.  
  14. GREEN = (0, 255, 0)
  15. RED = (255, 0, 0)
  16. BLUE = (0, 0, 255)
  17. BLACK = (0, 0, 0)
  18. WHITE = (255, 255, 255)
  19.  
  20. BOARDWIDTH = 800
  21. BOARDHEIGHT = 600
  22. DESIRED_FPS = 60
  23.  
  24. fpsClock = pygame.time.Clock()
  25.  
  26. testBox = rectCalc(BOARDWIDTH, BOARDHEIGHT, .95, .5, 1, 50, 50) #.95 gave perfectly modeled bouncing
  27. testBox2 = rectCalc(BOARDWIDTH, BOARDHEIGHT, .95, .5, 1, 100, 50)
  28. pygame.init()
  29. displaysurf = pygame.display.set_mode((BOARDWIDTH, BOARDHEIGHT))
  30.  
  31. while True: # main game loop
  32.     for event in pygame.event.get():
  33.         if event.type == pygame.QUIT:
  34.             pygame.quit()
  35.             sys.exit()
  36.         if event.type == pygame.KEYDOWN :
  37.             if event.key == pygame.K_RIGHT:
  38.                 testBox.pushX(12)
  39.             elif event.key == pygame.K_LEFT:
  40.                 testBox.pushSpecialX(12)
  41.             elif event.key == pygame.K_UP:
  42.                 testBox.jump(20)
  43.    
  44.     displaysurf.fill(BLACK)
  45.    
  46.     pygame.draw.rect(displaysurf, RED, testBox.returnMyRectangle())
  47.     pygame.draw.rect(displaysurf, BLUE, testBox2.returnMyRectangle())
  48.    
  49.     testBox.gravityAct()
  50.     testBox2.gravityAct()
  51.    
  52.     testBox.AirResistanceSlow(testBox.dx, testBox.dy) #Keep this last. It's where' the move method is fially called. Bundle em sometime, maybe
  53.     testBox2.AirResistanceSlow(testBox2.dx, testBox2.dy)
  54.    
  55.     pygame.display.update()
  56.     fpsClock.tick(DESIRED_FPS)
  57. #pygame.sprite.collide_rect(left, right):
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement