Guest User

Untitled

a guest
Feb 24th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. import pygame
  2. import sys
  3. from rocket import Rocket
  4.  
  5. class Game(object):
  6.  
  7. def __init__(self):
  8. # Configuration
  9. self.tps_max = 100.0
  10.  
  11. # Initialization
  12. pygame.init()
  13. self.screen = pygame.display.set_mode((1280, 720))
  14. self.tps_clock = pygame.time.Clock()
  15. self.tps_delta = 0.0
  16.  
  17. self.player = Rocket(self)
  18.  
  19. while True:
  20. # Handle events
  21. for event in pygame.event.get():
  22. if event.type == pygame.QUIT:
  23. sys.exit(0)
  24. elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
  25. sys.exit(0)
  26.  
  27. # Ticking
  28. self.tps_delta += self.tps_clock.tick() / 1000.0
  29. while self.tps_delta > 1 / self.tps_max:
  30. self.tick()
  31. self.tps_delta -= 1 / self.tps_max
  32.  
  33. # Drawing
  34. self.screen.fill((0, 0, 0))
  35. self.draw()
  36. pygame.display.flip()
  37.  
  38. def tick(self):
  39. self.player.tick()
  40.  
  41. def draw(self):
  42. self.player.draw()
  43.  
  44. if __name__ == "__main__":
  45. Game()
Add Comment
Please, Sign In to add comment