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 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 enter_pipe(a: example.Wrap1): if not vars.paused and vars.currentWarp != -1: a.setState('pipe', {}) info = example.getById(vars.currentWarp).getInfo() s = Script() s.add_action(act.Move(speed=100, by=[0, -64], tag='player')) s.add_action(act.CallFunc(goto_world(info['world'], info['start']))) example.play(s)
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)
def m2(x: float, y: float): def score(): m3(x, y + 1) a = entity.Sprite(model='sprites/01/flyingcoin', pos=(x * vars.tile_size, (y + 1) * vars.tile_size, 0)) main = example.get('main') id = main.add(a) s = script.Script() s.add_action( act.MoveAccelerated(v0=[0, 100], a=[0, -100], yStop=(y * vars.tile_size) + 16, entity_id=id)) s.add_action(act.RemoveEntity(id)) s.add_action(act.CallFunc(score)) example.play(s)
def downgrade_player(): vars.state -= 1 if vars.state < 0: player_dead() else: vars.invincibility = True pl = example.get('player') st = vars.states[vars.state] size = st['size'] offset = st['offset'] pl.setModel(st['model']) pl.setColliderBounds(size[0], size[1], size[2], offset[0], offset[1], offset[2]) s = Script() s.add_action(act.Blink(duration=5, blink_duration=0.2, entity_id=pl.id)) s.add_action(act.CallFunc(reset_invincible)) example.play(s)
def bonus_brick_response(player: example.Wrap1, brick: example.Wrap1, x, y): b = brick.parent() info = b.getInfo() hits_left = info['hitsLeft'] brick_id = b.id if hits_left > 0: info['hitsLeft'] -= 1 s = Script() ystop = b.y s.add_action( act.MoveAccelerated(v0=[0, 50], a=[0, 0.5 * vars.gravity], yStop=ystop, entity_id=brick_id)) if hits_left == 1: s.add_action(act.Animate(anim='taken', entity_id=brick_id)) # release the bonus def p(): info['callback'](b.x / vars.tile_size + 0.5, b.y / vars.tile_size) s.add_action(act.CallFunc(p)) example.play(s)