Esempio n. 1
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)
Esempio n. 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)    
Esempio n. 3
0
def brickResponse (player : example.Wrap1, brick : example.Wrap1, x, y):
    b = brick.parent()
    brick_id = b.id()
    if vars.state == 0:
        s = Script()
        ystop = b.y()
        s.addAction (act.MoveAccelerated (v0 = [0, 50], a = [0, 0.5 * vars.gravity], yStop = ystop, id = brick_id))
        example.play(s)
    else:
        print ('removing ' + str(brick_id))
        example.remove(brick_id)
        m = example.get('main')
        makePiece(pos = [b.x(), b.y(), 1], vx = 60, vy = 180, model ='brickpiece', parent=m)
        makePiece(pos = [b.x(), b.y(), 1], vx = -60, vy = 180, model ='brickpiece', parent=m)
        makePiece(pos = [b.x(), b.y(), 1], vx = 120, vy = 120, model ='brickpiece', parent=m)
        makePiece(pos = [b.x(), b.y(), 1], vx = -120, vy = 120, model ='brickpiece', parent=m)
Esempio n. 4
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)
Esempio n. 5
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)
Esempio n. 6
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)