예제 #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)
예제 #2
0
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)
예제 #3
0
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)
예제 #4
0
def win_slide(p: example.Wrap1, k, x, y):
    example.remove(k.id)
    p.setState('slide', {})
    s = Script()
    p.vy = 0
    s.add_action(act.Move(speed=50, to=[p.x, 48], tag='player'))
    s.add_action(act.SetState(tag='player', state='demo', args={'left': 0}))
    example.play(s)
예제 #5
0
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)
예제 #6
0
def fire_hits_foe(foe: example.Wrap1, fire: example.Wrap1, x, y):
    example.remove(fire.id)
    foe.setState('dead2', {})
    s = Script()
    s.add_action(
        act.MoveAccelerated(v0=[50 if fire.x < foe.x else -50, 150],
                            a=[0, vars.gravity],
                            yStop=-32,
                            entity_id=foe.id))
    s.add_action(act.RemoveEntity(entity_id=foe.id))
    example.play(s)
예제 #7
0
def make_piece(pos, vx, vy, model, parent: example.Wrap1):
    a = entity.Sprite(model=model, pos=pos)
    id = parent.add(a)
    s = Script()
    s.add_action(
        act.MoveAccelerated(entity_id=id,
                            v0=[vx, vy],
                            a=[0, 0.5 * vars.gravity],
                            yStop=0))
    s.add_action(act.RemoveEntity(entity_id=id))
    example.play(s)
예제 #8
0
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)
예제 #9
0
    def f():
        print(world_id)
        print(start_location)
        vars.invincibility = False
        # Don't reset energy! This only should be done after player dies!
        # vars.energy = vars.init_energy

        # Important! Reset these or otherwise you will get runtime errors!
        vars.currentWarp = -1

        vars.start_pos = start_location

        s = Script()
        s.add_action(act.ChangeRoom(world_id))
        example.play(s)
예제 #10
0
파일: shared.py 프로젝트: fabr1z10/glib3
    def walk(id, script_id='_main'):
        s = Script(uid=script_id)
        #has_item = vars.inventory.get(id, 0) > 0
        has_item = id in vars.inventory[
            vars.
            current_player] and vars.inventory[vars.current_player][id] > 0

        if not has_item:
            item = vars.items[id]
            wt = monkey.engine.read(item.get('walkto', None))
            if wt is not None:
                wdir = item.get('wdir', None)
                s.add_action(scumm.actions.Walk(pos=wt, tag='player'))
                if wdir is not None:
                    s.add_action(scumm.actions.Turn(dir=wdir, tag='player'))
        return s
예제 #11
0
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)
예제 #12
0
def brick_response(player: example.Wrap1, brick: example.Wrap1, x, y):
    # get the actual brick
    b = brick.parent()
    brick_id = b.id
    player.vy = -abs(player.vy)
    if vars.state == 0:
        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))
        example.play(s)
    else:
        # supermario
        piece = b.getInfo()['piece']
        example.remove(brick_id)
        m = example.get('main')
        make_piece(pos=[b.x, b.y, 1], vx=60, vy=180, model=piece, parent=m)
        make_piece(pos=[b.x, b.y, 1], vx=-60, vy=180, model=piece, parent=m)
        make_piece(pos=[b.x, b.y, 1], vx=120, vy=120, model=piece, parent=m)
        make_piece(pos=[b.x, b.y, 1], vx=-120, vy=120, model=piece, parent=m)
예제 #13
0
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)
예제 #14
0
def cippo():
    print('UEPA')
    #example.get('w1').setActive(False)
    if vars.start_pos in vars.disable_update_on_start:
        for i in vars.disable_update_on_start[vars.start_pos]:
            example.get(i).enableUpdate(False)
    s = Script()
    s.add_action(act.SetState(tag='player', state='pipe'))
    s.add_action(act.Move(tag='player', speed=50, by=[0, 64]))
    s.add_action(act.SetState(tag='player', state='walk'))
    example.play(s)
예제 #15
0
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)