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