diff --git a/src/gameUtils/base.py b/src/gameUtils/base.py index 7dafec0..903a50c 100644 --- a/src/gameUtils/base.py +++ b/src/gameUtils/base.py @@ -26,6 +26,10 @@ class Game: # The games serface self.surf = pygame.Surface(self._surf.size) self.size = self.surf.size + # Used for time delta, stores when the last frame was drawn + self._lastFrame = time.perf_counter() + # How many seconds it's been between frames + self.timeDelta = 0 # Pre-render semi-transparent black surface self._dimSurf = pygame.Surface(self._surf.size) self._dimSurf.set_alpha(128) @@ -70,6 +74,9 @@ class Game: self._surf.blit(self._dimSurf, (0, 0)) self._surf.blit(centre(self._popupMenu, self.size), (0, 0)) + self.timeDelta = time.perf_counter() - self._lastFrame + self._lastFrame = time.perf_counter() + def onEvent(self, event): """ Intended to be overridden by the game developer.