Ramaraunt1

Untitled

May 1st, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. import pygame
  2.  
  3. class Engine:
  4. def __init__(self):
  5. self.__screen = None
  6. self.__clock = None
  7. self.__windowShouldClose = False
  8. self.__objects = []
  9.  
  10. def revEngines(self, width=800,height=600,title="Stellar Engine"):
  11. if not pygame.display.get_init():
  12. pygame.init()
  13. self.__screen = pygame.display.set_mode((width,height))
  14. pygame.display.set_caption(title)
  15. self.__clock = pygame.time.Clock()
  16.  
  17. def stopEngines(self):
  18. pygame.display.quit()
  19. pygame.quit()
  20. quit()
  21.  
  22. def rebootDisplay(self, width=800,height=600,title="Stellar Engine"):
  23. if pygame.display.get_init():
  24. pygame.display.quit()
  25. pygame.quit()
  26. self.__screen = pygame.display.set_mode((width,height))
  27. pygame.display.set_caption(title)
  28.  
  29. def setFramerate(self, framerate=60):
  30. self.__clock.tick(framerate)
  31.  
  32. def getActualFramerate(self):
  33. return self.__clock.get_fps()
  34.  
  35. def getTimeSinceLastFrame(self):
  36. return self.__clock.get_time()
  37.  
  38. def getActualTimeSinceLastFrame(self):
  39. return self.__clock.get_rawtime()
  40.  
  41. def changeTitleBarText(self, title="Stellar Engine"):
  42. pygame.display.set_caption(self.__titleBarText)
  43.  
  44. def shouldClose(self):
  45. return self.__windowShouldClose
  46.  
  47. def closeWindow(self):
  48. self.__windowShouldClose = True
  49.  
  50. def pollEvents(self):
  51. for event in pygame.event.get():
  52. if event.type == pygame.QUIT:
  53. self.closeWindow()
  54. print (event)
  55.  
  56. def addObject(self, obj):
  57. self.__objects.append(obj)
  58.  
  59. def removeObject(self, obj):
  60. self.__objects.remove(obj)
  61.  
  62. def drawEvents(self):
  63. for obj in self.__objects:
  64. obj.draw()
  65.  
  66. def stepEvents(self):
  67. for obj in self.__objects:
  68. obj.step()
  69.  
  70. def singleStep(self):
  71. self.pollEvents()
  72. self.stepEvents()
  73. self.drawEvents()
Advertisement
Add Comment
Please, Sign In to add comment