Make module loading in game more sane.
This commit is contained in:
parent
f93dfb1fb2
commit
eb6b4b987c
@ -1,3 +1,4 @@
|
||||
def init(modules, aoEngineEvents):
|
||||
EngineEvent = modules['engineevents'].EngineEvent
|
||||
from engineevents import EngineEvent
|
||||
|
||||
def init(aoEngineEvents):
|
||||
aoEngineEvents.append(EngineEvent('level', lambda _: []))
|
||||
|
@ -1,10 +1,10 @@
|
||||
import importlib.resources as impr
|
||||
import sys
|
||||
import json
|
||||
import serialize
|
||||
from engineevents import EngineEvent
|
||||
|
||||
def init(modules, aoEngineEvents):
|
||||
serialize = modules['serialize']
|
||||
EngineEvent = modules['engineevents'].EngineEvent
|
||||
def init(aoEngineEvents):
|
||||
curm = sys.modules[__name__]
|
||||
files = impr.files(curm)
|
||||
level = None
|
||||
|
@ -1,10 +1,10 @@
|
||||
import importlib.resources as impr
|
||||
import sys
|
||||
import json
|
||||
import serialize
|
||||
from engineevents import EngineEvent
|
||||
|
||||
def init(modules, aoEngineEvents):
|
||||
serialize = modules['serialize']
|
||||
EngineEvent = modules['engineevents'].EngineEvent
|
||||
def init(aoEngineEvents):
|
||||
curm = sys.modules[__name__]
|
||||
files = impr.files(curm)
|
||||
level = None
|
||||
|
14
main.py
14
main.py
@ -2,6 +2,7 @@
|
||||
|
||||
from math import copysign, pi, acos
|
||||
import sys
|
||||
import os
|
||||
from importlib import import_module
|
||||
|
||||
import pygame
|
||||
@ -123,17 +124,7 @@ def mainLoop():
|
||||
except IndexError:
|
||||
game = import_module("games.squareroom")
|
||||
|
||||
game.init(
|
||||
{
|
||||
'serialize': import_module('serialize'),
|
||||
'alert': import_module('alert'),
|
||||
'gyro': import_module('gyro'),
|
||||
'engineevents': import_module('engineevents'),
|
||||
'constants': import_module('constants'),
|
||||
'lines': import_module('lines'),
|
||||
},
|
||||
aoEngineEvents
|
||||
)
|
||||
game.init(aoEngineEvents)
|
||||
processevents()
|
||||
|
||||
while bCont:
|
||||
@ -184,5 +175,6 @@ def main():
|
||||
return retstatus
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.path.append(os.path.realpath(__file__))
|
||||
if not main():
|
||||
print("An error occured")
|
||||
|
Loading…
Reference in New Issue
Block a user