def run_func(self, func): from amnesiac.game import getGameObject game = getGameObject() game.push(game._data[self.fname]) if hasattr(self.module, func): getattr(self.module, func)() game.pop()
def run_draw(self): from amnesiac.game import getGameObject game = getGameObject() t = time.time() game.dt = t - self.data["_time_draw"] self.data["_time_draw"] = t self.run_func("draw")
def run_save(self): from amnesiac.game import getGameObject game = getGameObject() self.run_func("save") try: os.makedirs(os.path.dirname(self.sfile)) except: pass with open(self.sfile, 'w') as f: json.dump(self.data, f)
from pyglet.window import key import random from amnesiac.game import getGameObject game = getGameObject() COUNTER="nexus-count" def init(): pass def main(): model=game.model player=game.player x,y = model.x,model.y # crossing x=63 between y=25 and y=38 if game.checkIntersectsRect(player.pos,(71,24,73,38)): game.loadLevel("$LEVEL/caves/open-air/index") game.setPos(7+x-71,y)
def run_init(self): from amnesiac.game import getGameObject game = getGameObject() game._data[self.fname] = self.data self.data["_time_main"] = self.data["_time_draw"] = time.time() self.run_func("init")