コード例 #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')
コード例 #2
0
ファイル: funcs.py プロジェクト: yasminsadi/games
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')
コード例 #3
0
ファイル: funcs.py プロジェクト: yasminsadi/games
def koopaResponse (player : example.Wrap1, koopa : example.Wrap1, x, y):
    if koopa.getState() == 'hide':
        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}))
        example.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()))
            example.play(s)     
        else:
            playerHitByEnemy(player)