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 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 #3
0
def goombaResponse (player : example.Wrap1, goomba : example.Wrap1, x, y):
    if (player.getState() == 'jump' and y > 0 and abs(x) < 0.01):
        s = Script()
        player.vy = 300
        s.addAction (act.SetState (state = 'dead', id = goomba.id ))
        s.addAction (act.Delay (sec = 2))
        s.addAction (act.RemoveEntity (id=goomba.id))
        example.play(s)        
    else:
        playerHitByEnemy(player)
Exemple #4
0
 def f(player, hotspot):
     s = Script()
     s.addAction (act.SetState(tag='player', state='demo', args = { 'left': 0 })),
     s.addAction (act.Delay (sec=1))
     s.addAction (act.SetState(tag='player', state='warp'))
     if newCamBounds:
         s.addAction (act.ChangeCamBounds('maincam', newCamBounds[0], newCamBounds[1], newCamBounds[2], newCamBounds[3]))
     s.addAction (act.Move(speed=0, to = [warpTo[0] * vars.tileSize, warpTo[1]*vars.tileSize], immediate= True, tag = 'player'))
     s.addAction (act.Move(speed=50, by =[0, 64], tag='player'))
     s.addAction (act.SetState(tag='player', state='walk'))
     example.play(s)
Exemple #5
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)
Exemple #6
0
def koopaResponse (player : example.Wrap1, koopa : example.Wrap1, x, y):
    if koopa.getState() == 'hide':
        koopa.killScripts()
        if (player.getState() == 'jump' and y > 0 and abs(x) < 0.01):
            player.vy = 300
        koopa.move(-10 * x, 0, 0)		
        left = 0 if (player.x <koopa.x) else 1
        s = Script()
        s.addAction (act.SetState(state='walk2', id=koopa.id, args = {'left': left}))
        koopa.play(s)
    else:
        if (player.getState() == "jump" and y > 0 and abs(x) < 0.01):
            player.vy = 300
            s = Script()
            s.addAction (act.SetState(state='hide', id=koopa.id))
            s.addAction (act.Delay(sec=2))
            s.addAction (act.Blink(duration=2,blink_duration=0.2,id=koopa.id))
            s.addAction (act.SetState(state='walk', id = koopa.id))
            koopa.play(s)
        else:
            playerHitByEnemy(player)
Exemple #7
0
def playerHitByEnemy(player : example.Wrap1):
    # if Mario is hit by enemy, what happens depends on whether mario is supermario or not
    #local marioInfo = player:getinfo()
    #local supermario = marioInfo.supermario
    if vars.state > 0:
        setPlayer(0)
        vars.invincibility = True
        # marioInfo.invincible = true
        # factory.mario.change_state(player, 1)
        # player.state = "walk"
        # local act = {
        # 	{ type = action.blink, args = { id = player.id, duration=5, blink_duration= 0.2}},
        # 	{ type = action.callfunc, args = { func = function() marioInfo.invincible=false end }}
        # }
        # local s = script.make(act)
        # monkey.play(s)
    else:
        s = Script()
        s.addAction (act.SetState(state='warp', tag='player', args = {'anim': 'dead'}))
        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(id = player.id()))
        s.addAction (act.RestartRoom())        
        example.play(s)
Exemple #8
0
# a: animate forward - async
# ab: aimate backward - async
# A: animate forward - sync
# Ab: animate backward - async
# d: delay
# (...) lines to say

# dialogue with anim control
# supercool and quick way to create a dialogue
d3h = {
    'a': lambda tag, c : actions.Animate (anim = c, tag = tag, fwd = True, sync = False),
    'ab': lambda tag, c : actions.Animate (anim = c, tag = tag, fwd = False, sync = False),
    'A': lambda tag, c : actions.Animate (anim = c, tag = tag, fwd = True, sync = True),
    'Ab': lambda tag, c : actions.Animate (anim = c, tag = tag, fwd = False, sync = True),
    'd': lambda tag, c: actions.Delay (sec = float(c))
}

def d3(s, *args):
    def f():
        sc = script.Script()
        an = True
        for b in args:
            tag = b[0]
            print (tag)
            for c in b[1:]:
                if isinstance(c, tuple):
                    animate = True if c[0] == 'a' else False
                    l = [s[x] for x in list(c[1:])]
                    #print ('say ' + str(l))
                    sc.addAction (sa.Say (lines = l, tag = tag, animate = animate))