Exemplo n.º 1
0
def koopa_response(player: example.Wrap1, koopa: example.Wrap1, x, y):
    if koopa.getState() == 'hide':
        koopa.killScripts()
        if player.getState() == 'jump' and player.vy < 0:
            player.vy = 300
        #koopa.move(-10 * x, 0, 0)
        left = 0 if (player.x < koopa.x) else 1
        s = Script()
        s.add_action(
            act.SetState(state='walk2',
                         entity_id=koopa.id,
                         args={'left': left}))
        koopa.play(s)
    elif koopa.getState() == 'walk2':
        # hit player only if going towards player
        dx = player.x - koopa.x
        if (dx > 0 and not koopa.flipx) or (dx < 0 and koopa.flipx):
            player_hit_by_enemy(player)

    else:
        if player.getState() == "jump" and player.vy < 0:
            print('fokkami')
            player.vy = 300
            s = Script()
            s.add_action(act.SetState(state='hide', entity_id=koopa.id))
            s.add_action(act.Delay(20))
            s.add_action(
                act.Blink(duration=2, blink_duration=0.2, entity_id=koopa.id))
            s.add_action(act.SetState(state='walk', entity_id=koopa.id))
            koopa.play(s)
        else:
            player_hit_by_enemy(player)
Exemplo n.º 2
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)