Example #1
0
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)
Example #2
0
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)
Example #3
0
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)
Example #4
0
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)
Example #5
0
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')
Example #6
0
def hotspotEnter (player: example.Wrap1, warp: example.Wrap1, x, y):
    info = warp.getInfo()
    if 'func' in info:
        info['func'](player, warp)
Example #7
0
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']
Example #8
0
def onCollectItem(player: example.Wrap1, item: example.Wrap1, x, y):
    f = item.getInfo()['func']
    print (f)
    print ('----')
    getattr(scr, f)(player, item, x, y)
Example #9
0
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)
Example #10
0
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)
Example #11
0
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)