Linted code, added documentation
This commit is contained in:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user