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 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):
|
||||||
"""
|
"""
|
||||||
@ -27,16 +29,24 @@ 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):
|
||||||
"""
|
"""
|
||||||
@ -62,12 +72,12 @@ class Game:
|
|||||||
|
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user