def run(self): self.load() self.boot() thread_runner = Service.get('engine.thread_runner') thread_runner.start() # scene_graph = Service.get('engine.scene_graph') message_bus = Service.get('engine.message_bus') try: from bearlibterminal import terminal terminal.open() terminal.printf(2, 2, "Test!") terminal.refresh() event = terminal.read() while event != terminal.TK_CLOSE: message_bus.emit('term.event', event, source='engine.main_window') terminal.refresh() event = terminal.read() terminal.close() except: from traceback import print_exc print("=== Exception Occured ===") print_exc()
def test(): blt.open() # blt.set("window: size=80x25, cellsize=auto, title='Omni: menu'; font: default") # blt.set("window: size=80x25, cellsize=auto, title='Omni: menu'; font: arial.ttf, size=8") # font: UbuntuMono-R.ttf, size=12" blt.set("window: size=80x25, cellsize=auto, title='Omni: menu'; font: .\Fonts\cp437_16x16_alpha.png, size=16x16, codepage=437") # font: UbuntuMono-R.ttf, size=12" blt.composition(blt.TK_ON) blt.color("white") test_basic_output() test_tilesets() blt.close()
def main(): terminal.open() terminal.set("window: title='Test!', size=80x25, cellsize=16x32;") terminal.set("input.filter=keyboard,mouse") terminal.set("font: res/font.png, size=12x24, codepage=437, align=top-left") terminal.set("0xE000: res/meph_32x32.png, size=32x32, align=top-left") terminal.set("0xE100: res/meph_trees.png, size=32x32, align=top-left") tx = 0 ty = 4 page = 0xE000 draw_page(tx, ty, page) terminal.refresh() event = terminal.read() while event != terminal.TK_CLOSE: terminal.clear() if event == terminal.TK_MOUSE_MOVE: mx = terminal.state(terminal.TK_MOUSE_X) my = terminal.state(terminal.TK_MOUSE_Y) terminal.printf(15, 0, "mx: {}, my: {}", mx, my) if mx >= tx and my >= ty: tid = page + (mx - tx) // 2 + (my - ty) * 16 terminal.printf(0, 3, "tile: {:04x}", tid) else: terminal.printf(0, 3, "tile: XXXX") elif event == terminal.TK_UP: page += 0x0100 elif event == terminal.TK_DOWN: page -= 0x0100 terminal.printf(0, 0, "event: {}", event) terminal.printf(0, 2, "page: {:x}", page) draw_page(tx, ty, page) terminal.refresh() event = terminal.read() terminal.close()
def close_window(): return terminal.close()
'Fireball Scroll', colours.dark_blue, item=item_component) objects.append(item) item.item.pick_up() message( 'Welcome stranger! Prepare to perish in the Tombs of the Ancient Kings.', colours.red) make_map() fov_recompute = True while player_action != 'exit': render_all() player_action = handle_keys() t.layer(OBJECT_LAYER) t.clear_area(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) if game_state == 'playing' and player_action != 'no-turn': for obj in objects: if obj.ai: obj.ai.take_turn() t.close()
def close_game(self): blt.close()
blt.puts( 1, view_height * 2 + 1, "[color=orange]Tip:[/color] use arrow keys to move viewport over the map" ) blt.refresh() key = blt.read() if key in (blt.TK_CLOSE, blt.TK_ESCAPE): break elif key == blt.TK_RIGHT and x0 < map_width - view_width: x0 += 1 elif key == blt.TK_LEFT and x0 > 0: x0 -= 1 elif key == blt.TK_DOWN and y0 < map_height - view_height: y0 += 1 elif key == blt.TK_UP and y0 > 0: y0 -= 1 blt.set("U+E000: none; U+E100: none;") if __name__ == "__main__": blt.open() blt.set( "window: size=80x25, cellsize=auto, title='Omni: menu'; font: default") blt.color("white") test_dynamic_sprites() blt.close()
game_state = GameStates.PLAYER_TURN if move and game_state == GameStates.PLAYER_TURN: point = player.position + move if not game_map.blocked(point): target = blocking_entities(entities, point) if target: print( f"You kick the {target} in the shins, much to its annoyance!" ) else: player.move(move) fov_update = True game_state = GameStates.ENEMY_TURN if __name__ == "__main__": terminal.open() terminal.composition(True) # logger.add( # "logs/build_maze_{time}.log", # level="ERROR", # format="{time:HH:mm:ss.SSS} {message}", # ) main() terminal.close()