Ejemplo n.º 1
0
def m3(x: float, y: float):
    a = spr('score100', x, y)
    main = example.get('main')
    id = main.add(a)
    s = Script()
    s.addAction(act.Move(speed=100, by=[0, 64], id=id))
    s.addAction(act.RemoveEntity(id=id))
    example.play(s)
Ejemplo n.º 2
0
def makePiece(pos, vx, vy, model, parent : example.Wrap1):
    a = Sprite(model = model, pos = pos)
    id = parent.add(a)
    s = Script()
    s.addAction (act.MoveAccelerated (id = id, v0 = [vx, vy], a = [0, 0.5*vars.gravity], yStop=0))
    s.addAction (act.RemoveEntity (id = id))
    #		type = action.remove_object, args = { id = id1}
    example.play(s)
Ejemplo n.º 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)    
Ejemplo n.º 4
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)
Ejemplo n.º 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)
Ejemplo n.º 6
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)
Ejemplo n.º 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)
Ejemplo n.º 8
0
 def f():
     s = script.Script()
     print('REMOVE ' + id)
     s.addAction(act.RemoveEntity(tag=id))
     s.addAction(sa.AddToInventory(id, 1))
     return s