예제 #1
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)
예제 #2
0
파일: funcs.py 프로젝트: fabr1z10/glib3
def fireHitsFoe(foe: example.Wrap1, fire: example.Wrap1, x, y):
    example.remove(fire.id)
    foe.setState ('dead2', {})
    s = Script()
    s.addAction (MoveAccelerated(v0=[50 if fire.x < foe.x else -50, 150], a=[0,vars.gravity], yStop = -32, id=foe.id))
    s.addAction (RemoveEntity (id=foe.id))
    example.play(s)
예제 #3
0
파일: scripts.py 프로젝트: fabr1z10/glib3
def winSlide(p: example.Wrap1, k, x, y):
    example.remove(k.id)
    p.setState('slide', {})
    s = Script()
    p.vy = 0
    s.addAction(Move(speed=50, to=[p.x, 48], tag='player'))
    s.addAction(SetState(tag='player', state='demo', args={'left': 0}))
    example.play(s)
예제 #4
0
파일: scripts.py 프로젝트: fabr1z10/glib3
def pipe_out(p: example.Wrap1, k, x, y):
    p.setState('demo', {'left': 0})
    addInfo = k.getInfo()['info']
    s = Script()
    from smb_py.funcs import gotoWorld
    s.addAction(Delay(sec=0.5))
    s.addAction(CallFunc(gotoWorld(addInfo['world'], addInfo['pos'])))
    example.play(s)
예제 #5
0
파일: scripts.py 프로젝트: fabr1z10/glib3
def enterPipe(a: example.Wrap1):
    if not vars.paused and vars.currentWarp != -1:
        a.setState('pipe', {})
        info = example.getById(vars.currentWarp).getInfo()
        s = Script()
        s.addAction(Move(speed=100, by=[0, -64], tag='player'))
        s.addAction(CallFunc(f=func.gotoWorld(info['world'], info['start'])))
        example.play(s)
예제 #6
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)
예제 #7
0
파일: funcs.py 프로젝트: fabr1z10/glib3
def goombaResponse (player : example.Wrap1, goomba : example.Wrap1, x, y):
    if (player.getState() == 'jump' and y > 0 and abs(x) < 0.01):
        s = Script()
        player.vy = 300
        s.addAction (act.SetState (state = 'dead', id = goomba.id ))
        s.addAction (act.Delay (sec = 2))
        s.addAction (act.RemoveEntity (id=goomba.id))
        example.play(s)        
    else:
        playerHitByEnemy(player)
예제 #8
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)
예제 #9
0
파일: scripts.py 프로젝트: fabr1z10/glib3
def gotoNext(p: example.Wrap1, k: example.Wrap1, x, y):
    #print (k.getInfo())
    addInfo = k.getInfo()['info']
    #print('world is ' + ['world'])
    example.remove(k.id)
    p.setActive(False)
    s = Script()
    from smb_py.funcs import gotoWorld
    s.addAction(Delay(sec=0.5))
    s.addAction(CallFunc(gotoWorld(addInfo['world'], addInfo['pos'])))
    example.play(s)
예제 #10
0
파일: funcs.py 프로젝트: yasminsadi/games
def goombaResponse (player : example.Wrap1, goomba : example.Wrap1, x, y):
    if vars.invincibility:
        return
    print ('qui')
    if (player.getState() == 'jump' and y > 0 and abs(x) < 0.01):
        s = Script()
        player.vy = 300
        s.addAction (act.SetState (state = 'dead', id = goomba.id() ))
        example.play(s)
        print ('ciao')
    else:
        playerHitByEnemy(player)
예제 #11
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')
예제 #12
0
파일: funcs.py 프로젝트: yasminsadi/games
def makePiece(pos, vx, vy, model, parent : example.Wrap1):
    a = Sprite(model = model, pos = pos)
    id = parent.add(a)
    s = Script()
    s.addAction (act.MoveAccelerated (id = id, v0 = [vx, vy], a = [0, 0.5*vars.gravity], yStop=0))
    s.addAction (act.RemoveEntity (id = id))
    #		type = action.remove_object, args = { id = id1}
    example.play(s)
예제 #13
0
def hit_brick_sensor(player, sensor : example.Wrap1, x, y):
    brick = sensor.parent()
    info = brick.getInfo()
    if info['hits_left'] > 0:
        info['hits_left'] -= 1
        sensor.parent().vy = 100
        # release item if any
        bonus = info.get('item', None)
        #print(bonus)
        #exit(1)
        if bonus:
            add_entity(bonus, [(brick.x + 8)/16, brick.y/16, 1], 'main')
            # item = mopy.monkey.engine.get_asset(bonus)
            # a = build_entity(item, )
            # example.get('main').add(a)
            #utils.create_entity(bonus, (brick.x + data.globals.tile_size[0] * 0.5, brick.y, -0.1), use_tile=False)
        if info['hits_left'] == 0:
            brick.setAnim('taken')
예제 #14
0
파일: funcs.py 프로젝트: fabr1z10/glib3
def onSpawn(player: example.Wrap1, spawn: example.Wrap1, x, y):
    # get the detail
    info = spawn.getInfo()
    fct = info['factory']
    func = data['factories']['items'][fct]
    props = info['info']
    delta = info['delta']
    foe = func ([None, props])([spawn.x/vars.tileSize + delta[0], spawn.y/vars.tileSize +delta[1]])
    example.get('main').add(foe)    
    example.remove(spawn.id)
예제 #15
0
def hit_basic_brick_sensor(player, sensor : example.Wrap1, x, y):
    brick = sensor.parent()
    if data.globals.player_mode == 0:
        brick.vy = 100
    else:
        player.vy = 0
        utils.create_entity("scripts.factories.brick_piece", (brick.x, brick.y, 1), use_tile=False, args={'model': 'brickpiece', 'vx': 60, 'vy': 180})
        utils.create_entity("scripts.factories.brick_piece", (brick.x, brick.y, 1), use_tile=False, args={'model': 'brickpiece', 'vx': -60, 'vy': 180})
        utils.create_entity("scripts.factories.brick_piece", (brick.x, brick.y, 1), use_tile=False, args={'model': 'brickpiece', 'vx': 120, 'vy': 120})
        utils.create_entity("scripts.factories.brick_piece", (brick.x, brick.y, 1), use_tile=False, args={'model': 'brickpiece', 'vx': -120, 'vy': 120})
        example.remove(brick.id)
예제 #16
0
파일: room.py 프로젝트: fabr1z10/glib3
def ciao(player : example.Wrap1, other : example.Wrap1, x, y):
    f = 'collide_with_'+other.tag
    print ('check if exists func ' + f)
    if hasattr(engine.scripts.actions, f):
        print ('YES')
        a = getattr(engine.scripts.actions, f)()
        if a:
            a()     
    else:
        print ('no')   
    example.remove(other.id())
예제 #17
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)
예제 #18
0
def on_spawn(player: example.Wrap1, spawn: example.Wrap1, x, y):
    # get the detail
    info = spawn.getInfo()
    fct = info['factory']
    func = monkey.engine.get_item_factory(fct)
    props = info['info']
    delta = info['delta']
    px = spawn.x / vars.tile_size + delta[0]
    py = spawn.y / vars.tile_size + delta[1]
    spawned = func(props)(px, py)
    example.get('main').add(spawned)
    example.remove(spawn.id)
예제 #19
0
파일: scripts.py 프로젝트: fabr1z10/glib3
def _fire(a: example.Wrap1, state: str):
    if vars.state >= 2:
        a.setState(state, {})
        b = Sprite(model='fire',
                   pos=[a.x + (-2 if a.flipx else 2), a.y + 16, 0])
        b.flipx = a.flipx
        b.addComponent(
            Controller2D(maskUp=vars.flags.platform,
                         maskDown=vars.flags.platform
                         | vars.flags.platform_passthrough,
                         maxClimbAngle=80,
                         maxDescendAngle=80))
        b.addComponent(GarbageCollect(10))
        b.addComponent(Dynamics2D(gravity=vars.gravity))
        b.addComponent(
            SmartCollider(flag=vars.flags.player_attack,
                          mask=vars.flags.foe | vars.flags.platform,
                          tag=vars.tags.player_fire))
        sm = StateMachine(initialState='jmp')
        sm.states.append(Bounce(id='jmp', speed=300, a=0, b=200))
        b.addComponent(sm)
        id = example.get('main').add(b)
예제 #20
0
def _fire(a: example.Wrap1, state: str):
    if vars.state >= 2:
        a.setState(state, {})
        b = entity.Sprite(model='fire',
                          pos=(a.x + (-2 if a.flipx else 2), a.y + 16, 0))
        b.flipx = a.flipx
        b.add_component(
            comp.Controller2D(mask_up=vars.flags.platform,
                              mask_down=vars.flags.platform
                              | vars.flags.platform_passthrough,
                              max_climb_angle=80,
                              max_descend_angle=80))
        b.add_component(comp.GarbageCollect(10))
        b.add_component(comp.Dynamics2D(gravity=vars.gravity))
        b.add_component(
            comp.SmartCollider(flag=vars.flags.player_attack,
                               mask=vars.flags.foe | vars.flags.platform,
                               tag=vars.tags.player_fire))
        sm = comp.StateMachine(initial_state='jmp')
        sm.states.append(
            platformer.states.Bounce(uid='jmp', speed=300, a=0, b=200))
        b.add_component(sm)
        example.get('main').add(b)
예제 #21
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)
예제 #22
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')
예제 #23
0
파일: funcs.py 프로젝트: yasminsadi/games
def brickResponse (player : example.Wrap1, brick : example.Wrap1, x, y):
    b = brick.parent()
    brick_id = b.id()
    if vars.state == 0:
        s = Script()
        ystop = b.y()
        s.addAction (act.MoveAccelerated (v0 = [0, 50], a = [0, 0.5 * vars.gravity], yStop = ystop, id = brick_id))
        example.play(s)
    else:
        print ('removing ' + str(brick_id))
        example.remove(brick_id)
        m = example.get('main')
        makePiece(pos = [b.x(), b.y(), 1], vx = 60, vy = 180, model ='brickpiece', parent=m)
        makePiece(pos = [b.x(), b.y(), 1], vx = -60, vy = 180, model ='brickpiece', parent=m)
        makePiece(pos = [b.x(), b.y(), 1], vx = 120, vy = 120, model ='brickpiece', parent=m)
        makePiece(pos = [b.x(), b.y(), 1], vx = -120, vy = 120, model ='brickpiece', parent=m)
예제 #24
0
파일: funcs.py 프로젝트: yasminsadi/games
def bonusBrickResponse (player: example.Wrap1, brick: example.Wrap1, x, y):
    b = brick.parent()
    info = b.getInfo()
    hitsLeft = info['hitsLeft']
    brick_id = b.id()
    if hitsLeft > 0:
        info['hitsLeft'] -= 1
        s = Script()
        ystop = b.y()
        s.addAction (act.MoveAccelerated (v0 = [0, 50], a = [0, 0.5 * vars.gravity], yStop = ystop, id = brick_id))
        if hitsLeft == 1:
           s.addAction (act.Animate (anim='taken', id=brick_id)) 
        # release the bonus
        def p():
            info['callback'](b.x()/ vars.tileSize + 0.5, b.y() / vars.tileSize)
        s.addAction (act.CallFunc (f = p))
        example.play(s)
예제 #25
0
파일: funcs.py 프로젝트: yasminsadi/games
def playerHitByEnemy(player : example.Wrap1):
    # if Mario is hit by enemy, what happens depends on whether mario is supermario or not
    #local marioInfo = player:getinfo()
    #local supermario = marioInfo.supermario
    if vars.state > 0:
        setPlayer(0)
        vars.invincibility = True
        # marioInfo.invincible = true
        # factory.mario.change_state(player, 1)
        # player.state = "walk"
        # local act = {
        # 	{ type = action.blink, args = { id = player.id, duration=5, blink_duration= 0.2}},
        # 	{ type = action.callfunc, args = { func = function() marioInfo.invincible=false end }}
        # }
        # local s = script.make(act)
        # monkey.play(s)
    else:
        s = Script()
        s.addAction (act.SetState(state='warp', tag='player', args = {'anim': 'dead'}))
        s.addAction (act.Delay(sec=1))
        s.addAction (act.MoveAccelerated(v0 = [0    , 200], a= [0, vars.gravity], yStop= 0, tag='player'))
        s.addAction (act.RemoveEntity(id = player.id()))
        s.addAction (act.RestartRoom())        
        example.play(s)
예제 #26
0
파일: funcs.py 프로젝트: yasminsadi/games
def coinResponse(player:example.Wrap1, coin:example.Wrap1, x, y):
    example.remove(coin.id())
예제 #27
0
파일: funcs.py 프로젝트: yasminsadi/games
def hotspotEnter (player: example.Wrap1, warp: example.Wrap1, x, y):
    info = warp.getInfo()
    if 'func' in info:
        info['func'](player, warp)
예제 #28
0
파일: funcs.py 프로젝트: yasminsadi/games
def warpEnter( player: example.Wrap1, warp: example.Wrap1, x,y):
    info = warp.getInfo()
    # set the warp function
    if 'func' in info:
        vars.warp_func = info['func']
예제 #29
0
파일: funcs.py 프로젝트: yasminsadi/games
def mushroomResponse (player: example.Wrap1, mushroom: example.Wrap1, x, y):
    example.remove(mushroom.id())
    upgradePlayer()
예제 #30
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)