Start making this thing into an actual game engine.
This commit is contained in:
parent
d28d1d10ed
commit
d9ce3fd3ab
11
games/squareroom/__init__.py
Normal file
11
games/squareroom/__init__.py
Normal 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("squareroom.json").open('r') as leveldir:
|
||||
level = json.loads(leveldir.read(), object_hook=serialize.object_hook)
|
||||
return level
|
1
games/squareroom/squareroom.json
Normal file
1
games/squareroom/squareroom.json
Normal file
@ -0,0 +1 @@
|
||||
[{"__type__": "objSegment", "isFinite": true, "pointA": {"__type__": "complex", "real": 0.6, "imag": 0.0}, "pointB": {"__type__": "complex", "real": 0.0, "imag": 0.6}, "color": [255, 0, 0]}, {"__type__": "objSegment", "isFinite": true, "pointA": {"__type__": "complex", "real": 0.6, "imag": 0.0}, "pointB": {"__type__": "complex", "real": 0.0, "imag": -0.6}, "color": [0, 255, 0]}, {"__type__": "objSegment", "isFinite": true, "pointA": {"__type__": "complex", "real": -0.6, "imag": 0.0}, "pointB": {"__type__": "complex", "real": 0.0, "imag": -0.6}, "color": [0, 0, 255]}, {"__type__": "objSegment", "isFinite": true, "pointA": {"__type__": "complex", "real": -0.6, "imag": 0.0}, "pointB": {"__type__": "complex", "real": 0.0, "imag": 0.6}, "color": [255, 255, 0]}]
|
7
main.py
7
main.py
@ -11,6 +11,7 @@ from levels import open_level, save_level, make_wall
|
||||
from constants import I, WHITE, BLACK, IROT, ROT, OFFSET
|
||||
from draw import draw
|
||||
from alert import Alert
|
||||
from importlib import import_module
|
||||
|
||||
gOrigin = GyroVector(0,1)
|
||||
|
||||
@ -113,9 +114,11 @@ def mainLoop():
|
||||
alert.start_hide_thread(alerts, delay)
|
||||
|
||||
try:
|
||||
level = open_level(sys.argv[1])
|
||||
game = import_module(sys.argv[1])
|
||||
except IndexError:
|
||||
level = open_level("maps/squareroom.json")
|
||||
game = import_module("games.squareroom")
|
||||
|
||||
level = game.init(import_module('serialize'))
|
||||
|
||||
while bCont:
|
||||
aoEngineEvents = fvControl_ao()
|
||||
|
Loading…
Reference in New Issue
Block a user