def goto_stage(p: example.Wrap1, k: example.Wrap1, x, y): add_info = k.getInfo()['info'] example.remove(k.id) p.setActive(False) s = Script() s.add_action(act.Delay(0.5)) s.add_action(act.CallFunc(goto_world(add_info['world'], add_info['pos']))) example.play(s)
def onSpawn(player: example.Wrap1, spawn: example.Wrap1, x, y): # get the detail info = spawn.getInfo() fct = info['factory'] func = data['factories']['items'][fct] props = info['info'] delta = info['delta'] foe = func ([None, props])([spawn.x/vars.tileSize + delta[0], spawn.y/vars.tileSize +delta[1]]) example.get('main').add(foe) example.remove(spawn.id)
def gotoNext(p: example.Wrap1, k: example.Wrap1, x, y): #print (k.getInfo()) addInfo = k.getInfo()['info'] #print('world is ' + ['world']) example.remove(k.id) p.setActive(False) s = Script() from smb_py.funcs import gotoWorld s.addAction(Delay(sec=0.5)) s.addAction(CallFunc(gotoWorld(addInfo['world'], addInfo['pos']))) example.play(s)
def on_spawn(player: example.Wrap1, spawn: example.Wrap1, x, y): # get the detail info = spawn.getInfo() fct = info['factory'] func = monkey.engine.get_item_factory(fct) props = info['info'] delta = info['delta'] px = spawn.x / vars.tile_size + delta[0] py = spawn.y / vars.tile_size + delta[1] spawned = func(props)(px, py) example.get('main').add(spawned) example.remove(spawn.id)
def foeIsHit(player : example.Wrap1, foe : example.Wrap1, x, y): # decrease foe energy info = foe.getInfo() info['energy'] -= 1 if info['energy'] <= 0: example.remove(foe.id()) else: foe.setState ('ishit', {}) vx = 200 if player.x() < foe.x() else -200 if foe.flipx: vx *= -1 foe.vx = vx print ('ciao')
def hotspotEnter (player: example.Wrap1, warp: example.Wrap1, x, y): info = warp.getInfo() if 'func' in info: info['func'](player, warp)
def warpEnter( player: example.Wrap1, warp: example.Wrap1, x,y): info = warp.getInfo() # set the warp function if 'func' in info: vars.warp_func = info['func']
def onCollectItem(player: example.Wrap1, item: example.Wrap1, x, y): f = item.getInfo()['func'] print (f) print ('----') getattr(scr, f)(player, item, x, y)
def on_leave_hotspot(player: example.Wrap1, item: example.Wrap1, x, y): info = item.getInfo() if 'on_leave' in info: info['on_leave'](player, item)
def on_enter_hotspot(player: example.Wrap1, item: example.Wrap1, x, y): info = item.getInfo() if 'on_enter' in info: info['on_enter'](player, item)
def on_collect_item(player: example.Wrap1, item: example.Wrap1, x, y): f = item.getInfo()['func'] getattr(sys.modules[__name__], f)(player, item, x, y)