Example #1
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')
Example #2
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)
Example #3
0
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)
Example #4
0
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)
Example #5
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)
Example #6
0
def hit_brick_sensor(player, sensor: example.Wrap1, x, y):
    sensor.parent().vy = 100