def pipe_out(p: example.Wrap1, k, x, y): p.setState('demo', {'left': 0}) add_info = k.getInfo()['info'] s = Script() s.add_action(act.Delay(0.5)) s.add_action(act.CallFunc(goto_world(add_info['world'], add_info['pos']))) example.play(s)
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)
def goto_stage(p: example.Wrap1, k: example.Wrap1, x, y): add_info = k.getInfo()['info'] example.remove(k.id) p.setActive(False) s = Script() s.add_action(act.Delay(0.5)) s.add_action(act.CallFunc(goto_world(add_info['world'], add_info['pos']))) example.play(s)
def goomba_response(player: example.Wrap1, goomba: example.Wrap1, x, y): if player.getState() == 'jump' and player.vy < 0: s = Script() player.vy = 300 s.add_action(act.SetState(state='dead', entity_id=goomba.id)) s.add_action(act.Delay(2)) s.add_action(act.RemoveEntity(goomba.id)) example.play(s) else: player_hit_by_enemy(player)
def player_dead(): s = Script() vars.state = 0 s.add_action(act.SetState(state='dead', tag='player')) s.add_action(act.Delay(1)) s.add_action( act.MoveAccelerated(v0=[0, 200], a=[0, vars.gravity], yStop=0, tag='player')) s.add_action(act.RemoveEntity(tag='player')) s.add_action(act.CallFunc(restart)) example.play(s)