From 9d6f775ab95e5ef2eedbcc968e83425ef8cf4a6e Mon Sep 17 00:00:00 2001 From: Brosef Date: Tue, 24 Jun 2025 06:04:20 +0100 Subject: [PATCH] Linted code, added documentation --- src/gameUtils/base.py | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/gameUtils/base.py b/src/gameUtils/base.py index b62bbc2..3ead71f 100644 --- a/src/gameUtils/base.py +++ b/src/gameUtils/base.py @@ -1,9 +1,11 @@ -from .events import Timeout -from .anim import AnimatedObject -import NoPELib import tomllib import time +import NoPELib + +from .events import Timeout +from .anim import AnimatedObject + class Game: def __init__(self, surface): """ @@ -26,18 +28,26 @@ class Game: """ Updates some core things in the background. """ - + + # Handle timeouts for timeout in self._timeouts.copy(): if timeout.fireOn <= time.perf_counter(): self.onEvent(timeout) self._timeouts.remove(timeout) def onEvent(self, event): - pass + """ + Intended to be overridden by the game developer. + See BaseGame for documentation. + """ + def close(self): - pass - + """ + Intended to be overridden by the game developer. + See BaseGame for documentation. + """ + def createAnimObj(self, *args, **kwargs): """ Creates an animated object. @@ -59,15 +69,15 @@ class Game: delay (float): How long (in seconds) to wait before firing. """ - + self._timeouts.append(Timeout(id, time.perf_counter()+delay)) - - def awaitingTimeout(self, id: str): + + def awaitingTimeout(self, timeoutID: str): """ Tells you if a timeout ID is on the timeout stack. Args: - id (str): The timeout ID. + timeoutID (str): The timeout ID. Returns: bool: True if there is a timeout with that ID