Change how paths to games are specified and add a new one.

This commit is contained in:
bʰedoh₂ swé 2024-04-07 15:59:26 +05:00
parent d9ce3fd3ab
commit c3858c548e
3 changed files with 13 additions and 1 deletions

View File

@ -0,0 +1,11 @@
import importlib.resources as impr
import sys
import json
def init(serialize):
curm = sys.modules[__name__]
files = impr.files(curm)
level = None
with files.joinpath("triangle.json").open('r') as leveldir:
level = json.loads(leveldir.read(), object_hook=serialize.object_hook)
return level

View File

@ -0,0 +1 @@
[{"__type__": "objSegment", "isFinite": true, "pointA": {"__type__": "complex", "real": 0.38529100476842437, "imag": 0.0}, "pointB": {"__type__": "complex", "real": -0.2372040619364459, "imag": 0.36629343026935063}, "color": [255, 0, 0]}, {"__type__": "objSegment", "isFinite": true, "pointA": {"__type__": "complex", "real": -0.2372040619364459, "imag": 0.36629343026935063}, "pointB": {"__type__": "complex", "real": -0.22354939429564802, "imag": -0.26820653903460523}, "color": [0, 255, 0]}, {"__type__": "objSegment", "isFinite": true, "pointA": {"__type__": "complex", "real": -0.22354939429564802, "imag": -0.26820653903460523}, "pointB": {"__type__": "complex", "real": 0.39868528559672944, "imag": 0.017873216691274733}, "color": [0, 0, 255]}]

View File

@ -114,7 +114,7 @@ def mainLoop():
alert.start_hide_thread(alerts, delay) alert.start_hide_thread(alerts, delay)
try: try:
game = import_module(sys.argv[1]) game = import_module('games.' + sys.argv[1])
except IndexError: except IndexError:
game = import_module("games.squareroom") game = import_module("games.squareroom")