Linted code, added documentation

This commit is contained in:
2025-06-24 06:04:20 +01:00
parent a9d95c65cb
commit 9d6f775ab9

View File

@ -1,9 +1,11 @@
from .events import Timeout
from .anim import AnimatedObject
import NoPELib
import tomllib import tomllib
import time import time
import NoPELib
from .events import Timeout
from .anim import AnimatedObject
class Game: class Game:
def __init__(self, surface): def __init__(self, surface):
""" """
@ -26,18 +28,26 @@ class Game:
""" """
Updates some core things in the background. Updates some core things in the background.
""" """
# Handle timeouts
for timeout in self._timeouts.copy(): for timeout in self._timeouts.copy():
if timeout.fireOn <= time.perf_counter(): if timeout.fireOn <= time.perf_counter():
self.onEvent(timeout) self.onEvent(timeout)
self._timeouts.remove(timeout) self._timeouts.remove(timeout)
def onEvent(self, event): def onEvent(self, event):
pass """
Intended to be overridden by the game developer.
See BaseGame for documentation.
"""
def close(self): def close(self):
pass """
Intended to be overridden by the game developer.
See BaseGame for documentation.
"""
def createAnimObj(self, *args, **kwargs): def createAnimObj(self, *args, **kwargs):
""" """
Creates an animated object. Creates an animated object.
@ -59,15 +69,15 @@ class Game:
delay (float): How long (in seconds) delay (float): How long (in seconds)
to wait before firing. to wait before firing.
""" """
self._timeouts.append(Timeout(id, time.perf_counter()+delay)) 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. Tells you if a timeout ID is on the timeout stack.
Args: Args:
id (str): The timeout ID. timeoutID (str): The timeout ID.
Returns: Returns:
bool: True if there is a timeout with that ID bool: True if there is a timeout with that ID