Example #1
0
def setup_bar():
    ra = mopy.monkey.engine.room_args
    gl = mopy.monkey.engine.data.globals
    bonus_left = Entity()
    bonus_left.model = gl.bonus_list[ra[0]]['gfx']
    bonus_left.pos = (2.5*16, 10.2*16, 0.11)
    example.get('main').add(bonus_left)
    bonus_right = Entity()
    bonus_right.model = gl.bonus_list[ra[2]]['gfx']
    bonus_right.pos = (9.5*16, 10.2*16, 0.11)
    example.get('main').add(bonus_right)




    from wbml.data.actions import WBM

    # check if player has enough gold to buy items
    min_cost = min(int(ra[1]), int(ra[3]))
    if gl.gold < min_cost:
        s = Script()
        s.seq([WBM('$msg/8'), act.ChangeRoom('citywl')])
        example.play(s)
    else:
        mopy.monkey.engine.data.globals.pos = [(2, 7.625, 0.1), (5.25, 7.625, 0.1), (9.5, 7.625, 0.1)]
        mopy.monkey.engine.data.globals.cpos = 1
        s = Script()
        s.seq([WBM('$msg/5')])
        example.play(s)
Example #2
0
def brick(ciao):
    e = Entity()
    e.model = ciao.get('model', None)
    hits_left = ciao.get('hits_left', 1)
    bonus_item = ciao.get('item', None)
    collision_tag = data.CollisionTags.bonus_brick_sensor if bonus_item else data.CollisionTags.basic_brick_sensor
    tile_size = getattr(monkey.engine.data.globals, 'tile_size', [1, 1])
    hidden = ciao.get('hidden', False)
    if hidden:
        collision_tag = data.CollisionTags.hidden_brick_sensor
    e.components.append({
        'type': 'components.collider',
        'shape': {
            'type': 'rect',
            'width': tile_size[0],
            'height': tile_size[1],
        },
        'tag': 0,
        'flag': 0 if hidden else 2,
        'mask': 0,
        'debug': True
    })
    e.components.append({
        'type': 'components.info',
        'stuff': {
            'hits_left': hits_left,
            'item': bonus_item
        }
    })
    e.components.append({'type': 'components.dynamics'})
    e.components.append({'type': 'components.platform'})
    e.components.append({
        'type': 'components.line_dynamic_mover',
        'direction': (0, 1),
        'acceleration': (0, -data.globals.gravity),
        'min': 0
    })
    # add brick sensor
    sensor = Entity()
    sensor.pos = [0.1 * tile_size[0], -0.1 * tile_size[1], 0]
    sensor.components.append({
        'type': 'components.collider',
        'shape': {
            'type': 'shape3d.aabb',
            'size': [0.8 * tile_size[0], 0.2 * tile_size[1], 0]
        },
        'tag': collision_tag,
        'mask': data.CollisionFlags.player,
        'flag': data.CollisionFlags.foe,
        'debug': True
    })

    e.add(sensor)
    return e
Example #3
0
 def f():
     aa = mopy.monkey.engine.read(msg_id)
     id = example.get('main').add(
         Text(font='sprites.mario_font',
              size=8,
              text=aa,
              color=[0, 0, 0, 0],
              maxwidth=160,
              align=TextAlignment.center,
              pos=[96, 132, 1.01]))
     text_size = example.getById(id).getTextSize()
     tw = (text_size[2] - text_size[0])
     th = (text_size[3] - text_size[1])
     width = math.ceil(tw / 8.0)
     height = math.ceil(th / 8.0)
     data = [22, 8]
     data.extend([23, 8] * width)
     data.extend([24, 8])
     md = [22, 7]
     md.extend([23, 7] * width)
     md.extend([24, 7])
     data.extend(md * height)
     data.extend([22, 6])
     data.extend([23, 6] * width)
     data.extend([24, 6])
     e = Entity(tag='msg_wrap')
     e.model = {
         'type': 'model.tiled',
         'tex': 'gfx/wbml.png',
         'img_tile_size': [8, 8],
         'tile_size': [8, 8],
         'size': [width + 2, height + 2],
         'data': data
     }
     e.pos = [96 - 0.5 * tw - 8, 132 - 0.5 * th - 8, 1]
     example.get('main').add(e)
     #s = Script()
     #acts=[]
     #print('positioned ' + str(text_size))
     id1 = example.get('main').add(
         Text(tag='ciaone',
              font='sprites.mario_font',
              size=8,
              text='',
              mode=1,
              color=[255, 255, 255, 255],
              shade_color=(255, 0, 0, 255),
              maxwidth=160,
              align=TextAlignment.top_left,
              pos=[96 - 0.5 * tw, 132 + 0.5 * th, 1.02]))
Example #4
0
def trunk(args):
    door = args.get('door')
    model = args.get('model', 'model.trunk')
    width = args.get('width', 6)
    xs = (width - 4) / 2
    tag = 'door_' + str(door)
    e = Entity()
    e.model = model
    door_info = mopy.monkey.engine.data.globals.doors[door]
    if door_info['open'] == 1:
        anim = door_info['anim']
    else:
        anim = 'barred'
    e.children.append(
        build_entity({
            'type': '_line',
            'size': [4, 0],
            'pass_thru': True
        }, [xs, 4]))

    e.children.append(
        build_entity(
            {
                'type': 'bg',
                'model': 'sprites.door',
                'anim': anim,
                'tag': tag
            }, [xs + 1, 0, 0]))
    # check if door is available
    if door_info['open'] == 1:
        coll = Entity()
        coll.add_component(
            Collider(
                shape={
                    'type': 'shape3d.aabb',
                    'size': [16, 32, 0]
                },
                flag=12,
                mask=mopy.monkey.engine.data.globals.CollisionFlags.player,
                tag=mopy.monkey.engine.data.globals.CollisionTags.door,
                debug=True))
        coll.pos = [(xs + 1.5) * 16, 0, 0]
        coll.add_component(Info(door_id=door))

        e.children.append(coll)
    return e
Example #5
0
def brick(ciao):
    e = Entity()
    tile_size = getattr(monkey.engine.data.globals, 'tile_size', [1, 1])
    e.components.append({
        'type': 'components.collider',
        'shape': {
            'type': 'rect',
            'width': tile_size[0],
            'height': tile_size[1],
        },
        'tag': 0,
        'flag': 2,
        'mask': 0,
        'debug': True
    })
    e.components.append({'type': 'components.dynamics'})
    e.components.append({'type': 'components.platform'})
    e.components.append({
        'type': 'components.line_dynamic_mover',
        'direction': (0, 1),
        'acceleration': (0, -data.globals.gravity),
        'min': 0
    })
    # add brick sensor
    sensor = Entity()
    sensor.pos = [0.1 * tile_size[0], -0.1 * tile_size[1], 0]
    sensor.components.append({
        'type': 'components.collider',
        'shape': {
            'type': 'shape3d.aabb',
            'size': [0.8 * tile_size[0], 0.2 * tile_size[1], 0]
        },
        'tag': data.CollisionTags.brick_sensor,
        'mask': data.CollisionFlags.player,
        'flag': data.CollisionFlags.foe,
        'debug': True
    })

    e.add(sensor)
    return e
Example #6
0
def pane():
    aa = mopy.monkey.engine.read('$msg/1')
    print(aa)
    id = example.get('main').add(Text(font='sprites.mario_font', size=8, text=aa, color=[0,0,0,0], maxwidth=160,align=TextAlignment.center, pos=[96, 132,1.01 ]))
    text_size = example.getById(id).getTextSize()
    # s.add_action(Msg(
    #     font=gl.msg_font,
    #     color=(127, 83, 30, 255),
    #     align=TextAlignment.center,
    #     text=mopy.monkey.engine.read(text),
    #     pos=(gl.sci_viewport[2] * 0.5, gl.sci_viewport[3] * 0.5, 1),
    #     inner_texture=gl.msg_inner_texture,
    #     border_texture=gl.msg_border_texture,
    #     eoc=True,
    #     timeout=1000,
    #     box=True,
    #     padding=(4, 5)))
    # s.add_action(sierra_enable_controls(True))
    # return s
    #s = Script()
    #
    #
    # print ('fottimilcazzzzo!!!!')
    #s.seq([
    #    act.AddEntity(entity_id='entities.textbg', pos=[0.5, 7, 1])
    #])
    import math
    tw = (text_size[2] - text_size[0])
    th = (text_size[3] - text_size[1])
    width = math.ceil(tw / 8.0)
    height = math.ceil(th / 8.0)
    data = [22, 8]
    data.extend([23, 8] * width)
    data.extend([24, 8])
    md = [22, 7]
    md.extend([23, 7] * width)
    md.extend([24, 7])
    data.extend(md * height)
    data.extend([22, 6])
    data.extend([23, 6] * width)
    data.extend([24, 6])
    e = Entity()
    e.model = {
            'type': 'model.tiled',
            'tex': 'gfx/wbml.png',
            'img_tile_size': [8, 8],
            'tile_size': [8, 8],
            'size': [width + 2, height + 2],
            'data': data}
    e.pos=[96 - 0.5 * tw - 8, 132 - 0.5*th - 8, 1]
    example.get('main').add(e)
    s = Script()
    acts=[]
    print('positioned ' + str(text_size))
    id1 = example.get('main').add(Text(tag='ciaone', font='sprites.mario_font', size=8, text=aa,
                                      color=[255,255,255,255], maxwidth=160,align=TextAlignment.top_left, pos=[96-0.5*tw, 132+0.5*th, 1.02]))
    for n in range(1, len(aa)+1):
        acts.append(act.SetText(tag='ciaone', text=aa[0:n]))
        acts.append(act.Delay(0.05))
    s.seq(acts)
    example.play(s)