Exemple #1
0
def playerIsHit(player: example.Wrap1, foe: example.Wrap1, x, y):
    # decrease foe energy
    #info = player.getInfo()
    #info['energy'] -= 1
    vars.energy -= 1
    func.updateEnergy()

    if vars.energy <= 0:
        x = player.x()
        y = player.y()
        vars.lives -= 1
        func.updateLives()
        example.remove(player.id())
        s = Script()
        s.addAction(act.Delay(sec=1))
        s.addAction(act.CallFunc(f=createPlayer(x, y)))
        s.addAction(act.CallFunc(f=restart))
        example.play(s)
    else:
        player.setState('ishit', {})
        vx = 200 if foe.x() < player.x() else -200
        if player.flipx:
            vx *= -1
        player.vx = vx
        print('ciao')
Exemple #2
0
    def f():
        def g():
            State.variables[var] = 'closed'

        s = script.Script()
        s.addAction(act.Animate(anim='closed', tag=doorId))
        s.addAction(act.CallFunc(f=g))
        return s
Exemple #3
0
def playerDead():
    s = Script()
    vars.state=0
    s.addAction (act.SetState(state='dead', tag='player'))
    s.addAction (act.Delay(sec=1))
    s.addAction (act.MoveAccelerated(v0 = [0    , 200], a= [0, vars.gravity], yStop= 0, tag='player'))
    s.addAction (act.RemoveEntity(tag = 'player'))
    s.addAction (act.CallFunc(f=restart))
    example.play(s)    
Exemple #4
0
    def f():
        def g():
            setattr(State.md.doors, var, 'open')
            #State.variables[var] = 'open'

        s = script.Script()
        s.addAction(act.Animate(anim='open', tag=doorId))
        s.addAction(act.CallFunc(f=g))
        return s
Exemple #5
0
def downgradePlayer():
    vars.state -= 1
    if vars.state < 0:
        playerDead()
    else:
        vars.invincibility = True
        pl = example.get('player')
        pl.setModel(vars.stateInfo[vars.state])
        s = Script()
        s.addAction (act.Blink (duration=5, blink_duration=0.2, id=pl.id))
        s.addAction (act.CallFunc (f = resetInvincible))
        example.play(s)
Exemple #6
0
def bonusBrickResponse (player: example.Wrap1, brick: example.Wrap1, x, y):
    b = brick.parent()
    info = b.getInfo()
    hitsLeft = info['hitsLeft']
    brick_id = b.id()
    if hitsLeft > 0:
        info['hitsLeft'] -= 1
        s = Script()
        ystop = b.y()
        s.addAction (act.MoveAccelerated (v0 = [0, 50], a = [0, 0.5 * vars.gravity], yStop = ystop, id = brick_id))
        if hitsLeft == 1:
           s.addAction (act.Animate (anim='taken', id=brick_id)) 
        # release the bonus
        def p():
            info['callback'](b.x()/ vars.tileSize + 0.5, b.y() / vars.tileSize)
        s.addAction (act.CallFunc (f = p))
        example.play(s)
Exemple #7
0
def m2(x: float, y: float):
    def score():
        m3(x, y + 1)

    a = spr('flyingcoin', x, y + 1)
    main = example.get('main')
    id = main.add(a)
    s = Script()
    s.addAction(
        act.MoveAccelerated(v0=[0, 100],
                            a=[0, -100],
                            yStop=(y * vars.tileSize) + 16,
                            id=id))
    s.addAction(act.RemoveEntity(id=id))
    s.addAction(act.CallFunc(f=score))
    #s.addAction(act.SetState (id = id, state='walk'))
    example.play(s)
Exemple #8
0
def handler2():
    # the rule is. Walk to item 2, but you need to HAVE item 1.
    # so if you 
    print ('A')
    sc = script.Script(id = '_main')
    if s.Config.item2:
        print ('B')
        item1 : s.Item = s.Data.items[s.Config.item1] # s.State.items[s.Config.item1]
        if s.State.has(s.Config.item1):
            handler2_do(sc)
        else:
            # try to pick up item1
            print ('try to pick up ' + s.Config.item1)
            walkto = helper.gdd(item1, 'walkto', None)
            wdir = helper.gdd (item1, 'wdir', None)
            if walkto is not None:
                sc.addAction( sa.Walk(pos = walkto, tag = 'player'))    
            if wdir is not None:
                sc.addAction( sa.Turn(dir = wdir, tag = 'player'))
            # ok, now check if pickup action is available            
            func = 'pickup_'+s.Config.item1
            if hasattr(engine.scripts.actions, func):
                a = getattr(engine.scripts.actions, func)()
                sc.addAction (actions.RunScript(s=a))        
                # now go to item 2 ONLY IF item is in inventory
                sc.addAction (actions.CallFunc (f = handler2_sub))
            else:
                # no pick up action, then do nothing.
                func = s.Config.verb + '_'
                if hasattr(engine.scripts.actions, func):
                    a = getattr(engine.scripts.actions, func)()
                    sc.addAction (actions.RunScript(s=a))  
        example.play(sc)           
    else:
        s.Config.wait_for_second_item = True
        print ('QUI')
        from lib_py.scumm.entity import update_current_action
        update_current_action()
Exemple #9
0
def cook():
    def setCookInKitchen():
        var.cook_in_kitchen = True

# if coming from kitchen, cook should be added to the scene!

    cook_pos = [125, 17]
    if engine.previous_room == 'kitchen':
        var.cook_in_kitchen = False
        s = Script()
        # make the cook
        cook = makeCook(cook_pos, 'n')
        s.addAction(actions.AddEntity(cook, 'walkarea'))
        s.addAction(actions.Delay(sec=5))
        s.addAction(act.Walk(tag='cook', pos=var.scummbar_kitchen_door_pos))
        s.addAction(actions.RemoveEntity(tag='cook'))
        s.addAction(actions.CallFunc(f=setCookInKitchen))
        example.play(s)
    else:
        var.cook_in_kitchen = True
        cook = makeCook(var.scummbar_kitchen_door_pos, 'w')
        s = Script()
        s.addAction(action=actions.Delay(sec=10), id=0)
        s.addAction(
            actions.RunScript(s=scr.openDoor(doorId='scummbar.door.kitchen',
                                             var='scummbar_kitchen')()))
        s.addAction(actions.AddEntity(cook, 'walkarea'))
        s.addAction(act.Walk(tag='cook', pos=cook_pos))
        s.addAction(act.Turn(tag='cook', dir='n'))
        s.addAction(actions.Delay(sec=5))
        s.addAction(act.Walk(tag='cook', pos=var.scummbar_kitchen_door_pos))
        s.addAction(actions.RemoveEntity(tag='cook'))
        s.addAction(
            actions.RunScript(s=scr.closeDoor(doorId='scummbar.door.kitchen',
                                              var='scummbar_kitchen')()))
        s.loop = 0
        example.play(s)