Example #1
0
def sierra_room(desc: dict):
    gl = mopy.monkey.engine.data.globals
    room = ScummRoom(desc)

    # read world size
    width = desc['width']
    height = desc['height']

    device_size = mopy.monkey.engine.device_size
    cam_width = device_size[0]
    cam_height = device_size[1]

    # add the main node
    room.default_item = 'main'
    main = Entity(tag='main')
    main.camera = OrthoCamera(width,
                              height,
                              gl.sci_viewport[2],
                              gl.sci_viewport[3],
                              gl.sci_viewport,
                              tag='maincam')
    main.add_component(
        HotSpotManager(lmbclick=sierra_walk_to, rmbclick=toggle_cursor))
    room.add(main)

    # add the ui node
    ui = Entity(tag='ui')
    ui.camera = OrthoCamera(cam_width, cam_height, cam_width, cam_height,
                            [0, 0, cam_width, cam_height])
    ui.add(
        Text(text=mopy.monkey.engine.title,
             color=gl.ui_txt_color,
             pos=(0, cam_height),
             align=TextAlignment.top_left,
             font=gl.msg_font,
             size=8))
    ui.add(
        Text(text=str(gl.score) + ' of ' + str(gl.max_score),
             color=gl.ui_txt_color,
             pos=(cam_width, cam_height),
             align=TextAlignment.top_right,
             font=gl.msg_font,
             size=8))
    room.add(ui)

    a = Sprite(model='01.cursor', tag='cursor')
    a.add_component(Cursor())
    a.pos = (0, 0, 5)
    main.add(a)
    # add static items
    room.add_items(desc)
    # add dynamic items
    room.load_dynamic_items()
    return room
Example #2
0
def dialogue_room(desc: dict):
    gl = mopy.monkey.engine.data.globals
    room = ScummRoom(desc)
    room.add_runner(Scheduler())
    room.init.append([refresh_inventory])
    # read world size
    width = desc['width']
    height = desc['height']

    device_size = mopy.monkey.engine.device_size
    cam_width = device_size[0]
    cam_height = device_size[1] - gl.ui_height

    # add the main node
    room.default_item = 'main'
    main = Entity(tag='main')
    main.camera = OrthoCamera(width,
                              height,
                              cam_width,
                              cam_height,
                              [0, gl.ui_height, cam_width, cam_height],
                              tag='maincam')
    room.add(main)

    # add the ui node
    ui = Entity(tag='ui')
    ui.camera = OrthoCamera(cam_width,
                            gl.ui_height,
                            cam_width,
                            gl.ui_height, [0, 0, cam_width, gl.ui_height],
                            tag='uicam')
    room.add(ui)

    # dialogue node
    dialogue_node = TextView(factory=make_dialogue_button,
                             pos=(0, 0),
                             size=(320, 56),
                             font_size=8,
                             lines=7,
                             delta_x=26,
                             tag='dialogue')
    dialogue_node.add_component(HotSpotManager())
    room.add(dialogue_node)

    inventory_node = Entity(tag='inventory')
    ui.add(inventory_node)

    # add static items
    room.add_items(desc)
    room.load_dynamic_items()
    return room
Example #3
0
def map_room(desc: dict):
    room = ScummRoom(desc)
    room.add_runner(Scheduler())
    # read world size
    width = desc['width']
    height = desc['height']

    device_size = mopy.monkey.engine.device_size
    cam_width = device_size[0]
    cam_height = device_size[1]
    # # add the main node
    room.default_item = 'main'
    main = Entity(tag='main')
    main.camera = OrthoCamera(width,
                              height,
                              cam_width,
                              cam_height, [0, 0, cam_width, cam_height],
                              tag='maincam')
    main.add_component(HotSpotManager(lmbclick=walk_to))
    room.add(main)
    # add static items
    room.add_items(desc)
    # add dynamic items
    room.load_dynamic_items()
    return room
Example #4
0
def map_room(desc: dict):
    gl = mopy.monkey.engine.data.globals
    room = ScummRoom(desc)
    room.add_runner(Scheduler())
    width = desc['width']
    height = desc['height']
    device_size = mopy.monkey.engine.device_size
    cam_width = device_size[0]
    cam_height = device_size[1]
    # add the main node
    room.default_item = 'main'
    main = Entity(tag='main')
    main.camera = OrthoCamera(width,
                              height,
                              cam_width,
                              cam_height, [0, 0, cam_width, cam_height],
                              tag='maincam')
    main.add_component(HotSpotManager(lmbclick=walk_to))
    room.add(main)
    cursor = Text(font=gl.default_font,
                  size=8,
                  text='#',
                  color=(255, 255, 255, 255),
                  tag='_cursor')
    cursor.add_component(Cursor())
    main.add(cursor)
    # add static items
    room.add_items(desc)
    # add dynamic items
    room.load_dynamic_items()
    return room
Example #5
0
    def __init__(self, desc):
        super().__init__(desc) #, 384, 224)
        #width =
        #height = 240
        #device_width = monkey.engine.device_size[0]
        #device_height = monkey.engine.device_size[1]
        device_size = mopy.monkey.engine.device_size
        device_width = device_size[0]
        device_height = device_size[1]
        width = desc['width']
        height = desc['height']

        keyl = KeyListener()
        keyl.add_key(key=299, func=restart)
        self.add_runner(keyl)

        main = Entity(tag='main')
        cam = Camera25(width, height, device_width, device_height, [0, 0, device_width, device_height])
        #cam = camera.PerspectiveCamera(viewport=[0, 0, 320, 240])
        cam.tag = 'maincam'
        cam.pos = (5, 0, 1)
        #cam.bounds = world_bounds
        #cam.boundsz = [-100, 22]
        main.camera = cam

        self.main = main
        self.add(main)

        ce = CollisionEngine3D(80, 80, 80)            # this will be a 3d engine
        #ce.add_response(vars.tags.player, vars.tags.ladder, runners.CollisionResponse(on_enter=func.on_enter_ladder_area, on_leave=func.on_leave_ladder_area))
        #ce.add_response(vars.tags.player, vars.tags.spawn, runners.CollisionResponse(on_enter=func.spawn))
        #ce.add_response(vars.tags.player_attack, vars.tags.foe, runners.CollisionResponse(on_enter=func.player_hits_foe))
        #ce.add_response(vars.tags.foe_attack, vars.tags.player, runners.CollisionResponse(on_enter=func.foe_hits_player))

        self.add_runner(ce)
        self.add_runner(Scheduler())
Example #6
0
def default_room(desc: dict):
    gl = mopy.monkey.engine.data.globals
    room = ScummRoom(desc)
    room.add_runner(Scheduler())
    room.init.append([refresh_inventory])
    # read world size
    width = desc['width']
    height = desc['height']

    device_size = mopy.monkey.engine.device_size
    cam_width = device_size[0]
    cam_height = device_size[1] - gl.ui_height

    # add the main node
    room.default_item = 'main'
    main = Entity(tag='main')
    main.camera = OrthoCamera(width,
                              height,
                              cam_width,
                              cam_height,
                              [0, gl.ui_height, cam_width, cam_height],
                              tag='maincam')
    main.add_component(HotSpotManager(lmbclick=walk_to))
    room.add(main)
    # get the verb set from the description. If not specified, verb set 0 will be used
    verb_set = desc.get('verb_set', 0)
    vset = gl.verb_sets[verb_set]
    dv = gl.verbs[vset['default_verb']]
    gl.current_verb = vset['default_verb']
    gl.current_item_1 = ''
    gl.current_item_2 = ''

    # add the ui node
    ui = Entity(tag='ui')
    ui.camera = OrthoCamera(cam_width,
                            gl.ui_height,
                            cam_width,
                            gl.ui_height, [0, 0, cam_width, gl.ui_height],
                            tag='uicam')
    ui.add(
        Text(font='fonts.ui',
             size=gl.font_size,
             text=mopy.monkey.engine.read(dv['text']),
             color=gl.Colors.current_action,
             align=TextAlignment.bottom,
             tag='current_verb',
             pos=(cam_width / 2, 48, 0)))
    ui.add_component(HotSpotManager())
    cy = gl.ui_height - 2 * gl.font_size
    count = 0
    shift = 0
    shift_applied = 46
    for i in vset['verbs']:
        cx = (count // 4) * shift_applied
        cy = gl.ui_height - (2 + count % 4) * gl.font_size
        e = make_verb_button(i, (cx, cy, 0))
        shift = max(shift,
                    1 + len(mopy.monkey.engine.read(gl.verbs[i]['text'])))
        ui.add(e)
        count += 1
    room.add(ui)
    # inventory node
    inventory_node = TextView(factory=make_inventory_button,
                              pos=(160, 0),
                              size=(160, 48),
                              font_size=8,
                              lines=6,
                              delta_x=26,
                              tag='inventory')
    inventory_node.add_component(HotSpotManager())
    ui.add(inventory_node)

    # dialogue node
    dialogue_node = TextView(factory=make_dialogue_button,
                             pos=(0, 0),
                             size=(320, 56),
                             font_size=8,
                             lines=7,
                             delta_x=26,
                             tag='dialogue')
    dialogue_node.add_component(HotSpotManager())
    room.add(dialogue_node)

    # add static items
    room.add_items(desc)
    # add dynamic items
    room.load_dynamic_items()
    # print (' ### looking up for dynamic items in room ' + desc['id'])
    # for r in mopy.monkey.engine.data.r2i.get(desc['id'], []):
    #     print('QUI')
    #     entity = create_dynamic(r)
    #     item = mopy.monkey.engine.data.items.get(r)
    #     print(item.get('parent', room.default_item) +' facomi')
    #     room.add(entity, item.get('parent', room.default_item))
    return room
Example #7
0
 def __init__(self, desc):
     self.id = desc['id']
     aa = desc.get('vars', None)
     room_info = monkey.engine.repl_vars(desc, aa)
     super().__init__(room_info['id'])
     device_size = monkey.engine.device_size
     on_preload = room_info.get('on_preload', None)
     on_load = room_info.get('on_load', None)
     scripts = room_info.get('scripts', None)
     self.tile_size = getattr(
         monkey.engine.data.globals, 'tile_size',
         [1, 1])  # monkey.engine.room_vars.get('tile_size', [1, 1])
     monkey.engine.data.globals.room_scaling = desc.get('scaling')
     if on_preload:
         on_preload(room_info)
     if on_load:
         func = on_load[
             'func']  # operator.attrgetter(on_load['func'])(monkey.engine.scripts)
         args = on_load.get('args', None)
         self.init.append([func, args] if args else [func])
     if scripts:
         for s in scripts:
             self.init.append([play_script(s), None])
     cams = room_info.get('cam')
     self.main = None
     self.default_item = None
     if cams:
         for cam in cams:
             cam_type = cam['type']
             id = cam['id']
             main = Entity(tag=id)
             if self.default_item is None:
                 self.default_item = id
             camera = None
             if cam_type == 'ortho':
                 world_size = cam['world_size']
                 cam_size = cam['cam_size']
                 viewport = cam.get('viewport', [
                     0, 0, monkey.engine.device_size[0],
                     monkey.engine.device_size[1]
                 ])
                 camera = OrthoCamera(world_size[0],
                                      world_size[1],
                                      cam_size[0],
                                      cam_size[1],
                                      viewport,
                                      tag='maincam')
                 camera.pos = cam.get('pos', [0, 0, 5])
                 bounds = cam.get(
                     'bounds', {
                         'x': [0, world_size[0]],
                         'y': [0, world_size[1]],
                         'z': [0, 100]
                     })
                 camera.boundsz = bounds['z']
                 camera.bounds = [
                     bounds['x'][0], bounds['y'][0], bounds['x'][1],
                     bounds['y'][1]
                 ]
             elif cam_type == 'perspective':
                 world_size = cam['world_size']
                 camera = PerspectiveCamera(
                     viewport=[0, 0, device_size[0], device_size[1]])
                 camera.pos = cam.get('pos', [0, 1, 5])
                 bounds = cam.get(
                     'bounds', {
                         'x': [0, world_size[0]],
                         'y': [0, world_size[1]],
                         'z': [0, 100]
                     })
                 camera.boundsz = bounds['z']
                 camera.bounds = [
                     bounds['x'][0], bounds['y'][0], bounds['x'][1],
                     bounds['y'][1]
                 ]
             else:
                 print('Unknown camera type: ' + cam_type)
                 exit(1)
             camera.tag = id + 'cam'
             main.camera = camera
             if not self.main:
                 self.main = main
             self.add(main)
     self.engines = room_info.get('engines', [])
     keyl = KeyListener()
     keyl.add_key(key=299, func=restart)
     self.add_runner(keyl)