Exemple #1
0
def main():
    # Opens and initializes terminal settings, then starts game.

    # Load config and adjust settings for the game based off of the config data.
    with open("config.json", "r") as read_file:
        config = json.load(read_file)

    config['tile_spacing_x'] = int(config['tile_font_width'] /
                                   config['cellsize_x'])
    config['tile_spacing_y'] = int(config['tile_font_height'] /
                                   config['cellsize_y'])
    config['window_width'] = config['camera_width'] * config['tile_spacing_x']
    config[
        'window_height'] = config['camera_height'] * config['tile_spacing_y']

    # Open terminal/config terminal.
    terminal.open()
    terminal.set("window: title='Etheria', size=%sx%s, cellsize=%sx%s" %
                 (config['window_width'], config['window_height'],
                  config['cellsize_x'], config['cellsize_y']))
    terminal.set("input.filter = [keyboard, mouse]")
    terminal.set(
        "text font: 'fonts/PxPlus_IBM_CGAthin.ttf', size=8x16, spacing=2x1")
    terminal.set(
        "bar font: 'fonts/PxPlus_IBM_CGAthin.ttf', size=4x4, spacing=1x6")
    terminal.set(
        "minimap font: 'fonts/PxPlus_IBM_CGAthin.ttf', size=4x4, spacing=1x2")
    terminal.set("main font: 'fonts/VeraMono.ttf', size=20x20, spacing=5x5")
    terminal.font('main')
    terminal.composition(True)

    # Start the game, close the terminal after game is exited.
    start_game(config)
    terminal.close()
Exemple #2
0
    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()
Exemple #3
0
    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 main_blt(options):
    from bearlibterminal import terminal as t
    escape_codes = [t.TK_Q, t.TK_ESCAPE, 224]
    t.open()
    t.set("window.title='Storyboard'")
    t.set("input.filter={keyboard, mouse+}")
    b = Board(options)
    b.import_using(DataFormat.JSON, "data/storyboard.json")
    b.import_using(DataFormat.JSON, "data/storyboard2.json")
    t.puts(0, 1, b.board)

    footer_options = ['Add', 'Edit', 'Delete', 'Save']
    footer = '  '.join(f"[color=red]{o[0]}[/color][color=grey]{o[1:]}[/color]"
                       for o in footer_options)
    t.puts(0, 0, f"[bkcolor=grey]{' '*80}[/bkcolor]")
    t.puts(0, 24, f"[bkcolor=white]{' '*80}[/bkcolor]")
    t.puts(1, 24, footer)
    t.puts(1, 0, f"[color=white]{'File  Edit  View  Help'}[/color]")

    t.refresh()
    char = None
    while True:
        char = t.read()
        if char in escape_codes:
            break
Exemple #5
0
def main():
    terminal.open()
    terminal.set("window.title='Scrollable Calendar Grid'")
    terminal.set("input.filter={keyboard, mouse+}")
    escape_codes = [terminal.TK_Q, terminal.TK_ESCAPE, 224]

    b = TextBox(point(0, 0), 80, 25, "asdf" * 10)
    b.split_x()
    b.l.split_y()
    b.r.split_y()

    c = None
    while True:
        terminal.clear()
        for (x, y, s) in b.blt_border():
            terminal.puts(x, y, s)
        for (x, y, s) in b.blt_text():
            terminal.puts(x, y, s)
        terminal.refresh()
        c = terminal.read()

        if c in escape_codes:
            break
        if b.l.split:
            b.l.join()
            continue
        elif b.r.split:
            b.r.join()
            continue
        b.join()
Exemple #6
0
def start():
    try:
        title = "Gold Miner"
        size = "{}x{}".format(settings.initial_screen_width,
                              settings.initial_screen_height)
        minimun_size = size

        font = assets.font_default
        font_size = 12
        # cell_size = "7x11"
        cell_size = "auto"

        resizeable = "true" if settings.resizeable else "false"
        full_screen = "true" if settings.full_screen else "false"

        terminal.open()
        terminal.set("window.size={}".format(size))
        terminal.set("window.minimun-size={}".format(minimun_size))
        terminal.set("window.resizeable={}".format(resizeable))
        terminal.set("window.fullscreen={}".format(full_screen))
        terminal.set("window.cellsize={}".format(cell_size))
        terminal.set("window.title='{}'".format(title))
        terminal.set("font: {}, size={}".format(font, font_size))
        terminal.set("input: filter=[keyboard],alt-functions=false")

        settings.update()

        show_menu()
        game_loop()
    finally:
        terminal.close()
Exemple #7
0
def blt_setup():
    terminal.open()
    terminal.set("input: filter=[keyboard,mouse]")
    terminal.set("U+E100: ./source/images/sword.png, size=8x16")
    terminal.set("U+E200: ./source/images/health.png, size=8x16")
    terminal.set("U+E300: ./source/images/mana.png, size=8x16")
    terminal.set("U+E400: ./source/images/shield.png, size=16x16")
Exemple #8
0
def initialize_screen():
    blt.open()
    blt.set(
        "window: size=120x40, cellsize=auto, title='roguelike dev does the tutorial'; font: default"
    )
    blt.bkcolor(blt.color_from_name('0,0,0'))
    blt.composition(True)

    # needed to avoid insta-close
    blt.refresh()
    blt.color('white')

    # tiles
    # we use Unicode code point 3002 instead of a normal dot because the dot will be necessary for message log
    blt.set("0x3002: gfx/stonefloor.png, align=top-left")
    # no such problems with @ and #
    blt.set("0x23: gfx/wall.png, align=top-left")  # "#"
    blt.set("0x40: gfx/human_m.png, align=top-left")  # "@"
    blt.set("0x003E: gfx/stairs.png, align=top-left")  # ">"
    # items
    blt.set("0x2215: gfx/longsword.png, align=center")  # "∕"
    blt.set("0x203D: gfx/scroll.png, align=center")  # "‽"
    # NPCs (we use Unicode private area here)
    blt.set("0xE000: gfx/kobold.png,  align=center")  # ""
    blt.set("0xE001: gfx/goblin.png, align=center")
Exemple #9
0
def main():
    global game_map

    terminal.open()
    terminal.set("window.size = " + str(WINDOW_WIDTH) + "x" + str(GAME_HEIGHT))
    terminal.set("font: square.ttf, size=14;")

    # terminal.set("U+E500: ./Media/test.png, resize=128x128, resize-filter=nearest")
    # terminal.set("U+E000: ./at.png")
    # terminal.set("U+E100: ./period.png")
    # terminal.set("U+E200: ./question.png")

    game_map = wild_gen.gen()

    playing = True

    render()

    while playing:

        playing = handle_keys()

        render()

    terminal.close()
def main():
    terminal.open()

    # generate opening scene
    UIManager.push(TitleScene())
    key = 0
    shift_down = False

    # main game loop
    while key != terminal.TK_CLOSE:
        terminal.clear()
        UIManager.render()
        terminal.refresh()
        GAME.scheduler.process()
        key = terminal.read()
        shift_down = bool(terminal.check(terminal.TK_SHIFT))
        player_cmd = UIManager.peek().handle_input(key, shift_down)
        GAME.player.push_player_action(player_cmd)

        # if no UIs to show, game is closed
        if UIManager.empty:
            break

    # cleanup
    UIManager.clear()  # if the close button was clicked with UIs on the stack
    terminal.close()
Exemple #11
0
 def init_tilesets(self, raw_tileset_data):
     first_tileset = True
     for tileset in raw_tileset_data:
         resolution = tileset['resolution']
         if first_tileset:
             self.resolution = resolution
             blt.open()
             config_string = "window: size=30x20, cellsize={0}x{0}, title='Wangview'".format(
                 self.resolution)
             blt.set(config_string)
             tileset_offset_counter = 0xE000
             self.tilesets = {}
             first_tileset = False
         assert(self.resolution == resolution)
         rx = tileset['x']//self.resolution
         ry = tileset['y']//self.resolution
         filename = tileset['filename']
         self.tilesets[filename] = Tileset(
             filename, tileset_offset_counter,
             rx,ry, tuple(tileset['terrains']))
         config_string = "0x{0:x}: {1}, size={2}x{2}".format(
                 tileset_offset_counter,
                 path.join(self.rel_path, filename),
                 self.resolution)
         blt.set(config_string)
         tileset_offset_counter += rx*ry
Exemple #12
0
def main():
	"""Setup screen and start main menu"""
	pixels_w = 12 * SCREEN_WIDTH
	pixels_h = 12 * SCREEN_HEIGHT

	#ENSURE Save directory exists
	if not os.path.isdir(SAVE_PATH):
	os.makedirs(SAVE_PATH)

	t.open()

	mapsize = str(SCREEN_WIDTH) + "x" + str(SCREEN_HEIGHT)
	t.set("window: size=" + mapsize + ", resizeable=true")
	t.set("window.title=The Cool Roguelike Project")
	t.set("font: ./terminal12x12_gs_ro.png, size=12x12")
	t.set("input.filter={keyboard, mouse+}")
	t.set("0x5E: cleaving_minotaur.jpg, resize=" + str(pixels_w) + "x" + str(pixels_h))

	mainmenu = MainMenuScene()

	scene_manager.append(mainmenu)

	#while there is a scene to process don't exit
	while scene_manager:



if __name__ == "__main__":
	main()
Exemple #13
0
    def __init__(self) -> None:
        self.game = Game()
        messages.on_log += self.on_log

        blt.open()

        self.root = DisplayElement.DisplayDict(vec(0, 0))

        half_width = blt.state(blt.TK_WIDTH) // 2
        half_height = blt.state(blt.TK_HEIGHT) // 2
        half_window = vec(half_width, blt.state(blt.TK_HEIGHT))
        quarter_window = vec(half_width, half_height)
        event_log = DisplayElement.PrintArgs(
            text='',
            xy=vec(0, 0),
            bbox=half_window,
            align_v=DisplayElement.TextAlignmentV.Bottom)
        self.root.elements['events'] = DisplayElement.Clickable(
            event_log, Rectangle(vec(0, 0), half_window))

        hta_origin = vec(half_width, 0)
        hta_display = DisplayElement.DisplayList(hta_origin)
        self.root.elements[self.game.hta] = DisplayElement.Clickable(
            hta_display, Rectangle(hta_origin, quarter_window))
        self.on_tableau_altered(self.game.hta)

        htb_origin = quarter_window
        htb_display = DisplayElement.DisplayList(htb_origin)
        self.root.elements[self.game.htb] = DisplayElement.Clickable(
            htb_display, Rectangle(htb_origin, quarter_window))
        self.on_tableau_altered(self.game.htb)
Exemple #14
0
    def open_blt_terminal(*args, **kwargs):
        # print('Open blt')
        blt.open()
        blt.composition(True)
        # print('start game')

        fn(*args, **kwargs)
        blt.close()
Exemple #15
0
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 __init__(self):
     terminal.open()
     terminal.set(
         f"window: title={self.game_title}, size={self.window_width}x{self.window_height}; font: MegaFont.ttf, size={self.tile_size}"
     )
     intro_text = '                '
     #terminal.printf(self.center_text(intro_text), 1, intro_text)
     terminal.printf(self.center_text(intro_text), 12, intro_text)
     terminal.refresh()
     input_listener(self)
Exemple #17
0
 def run(self):
     blt.open()
     blt.set(f"window.size={self.width}x{self.height}")
     self.new_game()
     self.stop = False
     while not self.stop:
         self.draw()
         sleep(0.01)
         self.read()
     pass
Exemple #18
0
def terminal_context():
    terminal.open()
    terminal.set("""
    window.title='Two Button Berserker';
    font: data/UbuntuMono-R.ttf, size=18;
    window.size=84x21;
    input.filter=[keyboard+];
    """)
    yield
    terminal.close()
Exemple #19
0
def game_initialize():
    global GAME, PLAYER, FOV_CALCULATE

    blt.open()
    # default terminal size is 80x25
    # we need nonstandard size to fit the test map
    blt.set("window: size=120x25, cellsize=auto, title='roguelike dev does the tutorial'; font: default")

    # we need composition to be able to draw tiles on top of other tiles
    blt.composition(True)

    # needed to avoid insta-close
    blt.refresh()
    blt.color('white')
    # tiles
    # we use Unicode code point 3002 instead of a normal dot because the dot will be necessary for message log
    blt.set("0x3002: gfx/floor_sand.png, align=center")
    # no such problems with @ and #
    blt.set("0x23: gfx/untitled.png, align=center")  # "#"
    blt.set("0x40: gfx/human_m.png, align=center")  # "@"
    blt.set("0x003E: gfx/stairs_down.png, align=center")  # ">"
    # items
    blt.set("0x2215: gfx/longsword.png, align=center")  # "∕"
    blt.set("0x203D: gfx/scroll.png, align=center") # "‽"
    # NPCs (we use Unicode private area here)
    blt.set("0xE000: gfx/kobold.png,  align=center")  # ""
    blt.set("0xE001: gfx/goblin.png, align=center")

    # if we have a savegame, load it
    '''
    if os.path.isfile('savegame.json'):
        GAME, PLAYER = load_game()

        # fix player ref
        # player is always last in the entities list
        # the assumption isn't true if you pick up and drop some items
        # so we handle it in load_game()
        #player_id = len(GAME.current_entities) - 1
        #GAME.current_entities[player_id] = PLAYER

        # handle FOV
        FOV_CALCULATE = True
        # recreate the fov
        global FOV_MAP
        FOV_MAP = map_make_fov(GAME.current_map)

        # fix issue where the map is black on turn 1
        map_calculate_fov()

    else:
    '''
    GAME, PLAYER, FOV_CALCULATE = start_new_game()

        # fix issue where the map is black on turn 1
    map_calculate_fov()
Exemple #20
0
 def initialize_blt(self):
     logger.debug("initializing bearlibterminal")
     blt.open()
     blt.set(
         "window: size={}x{}, title='roguelike-bearlib';"
         "".format(
             str(self.window_width),
             str(self.window_height)))
     blt.clear()
     blt.refresh()
     blt.bkcolor('t_black')
Exemple #21
0
    def __init__(self):
        #####################################
        # Initialize BearLibTerminal Window #
        #####################################
        terminal.open()
        font = f'font: MegaFont.ttf, size={self.tile_size}'
        terminal.set(f"window: title={self.title}; {font}")
        terminal.set("input.filter = keyboard+, mouse+")
        terminal.printf(25, 2, self.title)
        terminal.composition(terminal.TK_ON)
        terminal.refresh()
        '''
		display = Display()
		root = display.screen().root
		printWindowHierrarchy(root, '-')
		'''
        self.window_id = get_current_win()
        ###################################################################
        # Global Hotkeys using the keyboard module as a low level wrapper #
        ###################################################################
        keyboard.add_hotkey(config.get('innit', 'key_toggle'),
                            self.global_hotkey,
                            args=(' '))
        keyboard.add_hotkey('ctrl+shift+esc', self.global_hotkey, args=('s'))
        keyboard.add_hotkey(config.get('innit', 'key_next'),
                            self.global_hotkey,
                            args=('n'))
        keyboard.add_hotkey(config.get('innit', 'key_prev'),
                            self.global_hotkey,
                            args=('b'))
        keyboard.add_hotkey(config.get('innit', 'key_pause'),
                            self.global_hotkey,
                            args=('p'))
        keyboard.add_hotkey(config.get('innit', 'key_volup'),
                            self.global_hotkey,
                            args=('u'))
        keyboard.add_hotkey(config.get('innit', 'key_voldn'),
                            self.global_hotkey,
                            args=('m'))
        keyboard.add_hotkey(config.get('innit', 'key_stop'),
                            self.global_hotkey,
                            args=('s'))
        keyboard.add_hotkey(config.get('innit', 'key_mark_watched'),
                            self.global_hotkey,
                            args=('w'))
        # these keys only work when the program is in focus
        keyboard.add_hotkey('enter', self.global_hotkey, args=('f'))
        keyboard.add_hotkey('space', self.global_hotkey, args=(' '))
        keyboard.add_hotkey('esc', self.global_hotkey, args=('q'))
        keyboard.add_hotkey('left', self.global_hotkey, args=('4'))
        keyboard.add_hotkey('right', self.global_hotkey, args=('6'))
        keyboard.add_hotkey('up', self.global_hotkey, args=('8'))
        keyboard.add_hotkey('down', self.global_hotkey, args=('2'))
        self.start_main_loop()
Exemple #22
0
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()
Exemple #23
0
    def run(self):
        terminal.open()
        self.terminal_init()
        terminal.refresh()

        try:
            asyncio_loop = asyncio.get_event_loop()
            asyncio_loop.run_until_complete(self.loop_until_terminal_exits())
        except KeyboardInterrupt:
            pass
        finally:
            terminal.close()
Exemple #24
0
    def start(self):
        """
        Open a terminal and place it on the screen.

        Library settings that were passed as kwargs to `self.__init__()` get
        actually applied during when this method is executed.
        """
        terminal.open()
        terminal.set(
            'font: {}, size=12x12, codepage=437'.format(self.font_path))
        if self.outstring:
            terminal.set(self.outstring)
        self.refresh()
Exemple #25
0
 def __init__(self):
     self.info = info.InfoBar()
     self.world = world.World(50, 50, self.info)
     self.player = player.Player("Frederico", self.world)
     self.world.create_enemies()
     self.gui = gui.GUI(self.player)
     terminal.open()
     terminal.set("window: title='Frederico', size={0}x{1}".format(
         vars.CONSOLE_WIDTH, vars.CONSOLE_HEIGHT))
     terminal.set(
         "0xE000: resources/materials.png, size=16x16, resize=32x32, spacing=2x1"
     )
     self.game_loop()
     self.quit = False
Exemple #26
0
    def run(self):
        """
        Start the event loop.
        """
        terminal.open()
        self.terminal_init()
        terminal.refresh()

        try:
            self.loop_until_terminal_exits()
        except KeyboardInterrupt:
            pass
        finally:
            terminal.close()
Exemple #27
0
    def initialize(self):
        # Initialize game data from external files
        game_data = json_data.JsonData()
        json_data.data = game_data
        self.data = game_data

        window_title = 'SpiritQuestRL'
        size = 'size=200x80'
        title = 'title=' + window_title
        cellsize = 'cellsize=auto'
        resizable = 'resizeable=true'
        window = "window: " + size + "," + title + "," + cellsize + "," + resizable

        blt.composition(True)
        blt.open()
        blt.set(window)
        blt.set("font: default")
        blt.set("input: filter=[keyboard]")

        # Needed to avoid insta-close and flush the input queue
        blt.refresh()
        blt.read()

        self.options = Options()

        # Load tiles
        init_tiles(self.options)

        # Init UI
        self.ui = UIElements()
        self.ui.owner = self

        self.actions = Actions()
        self.actions.owner = self

        self.render_functions = RenderFunctions(self.ui.offset_x,
                                                self.ui.offset_y)
        self.render_functions.owner = self

        self.ui.draw()

        # Call main menu and start game loop
        main_menu_component = MainMenu(title_screen=True)
        self.menus = Menus(main_menu=main_menu_component)
        self.menus.owner = self

        self.menus.main_menu.show()

        self.menus.main_menu.title_screen = False
        self.game_loop()
Exemple #28
0
def main():
    blt.open()

    entries = (
        ("Basic output", test_basic_output),
        ("Default font", test_default_font),
        ("Tilesets", test_tilesets),
        ("Sprites", test_sprites),
        ("Manual cellsize", test_manual_cellsize),
        ("Auto-generated tileset", test_auto_generated),
        ("Multiple fonts", test_multiple_fonts),
        ("Text alignment", test_text_alignment),
        ("Formatted log", test_formatted_log),
        ("Layers", test_layers),
        ("Extended 1: basics", test_extended_basics),
        #("Extended 2: inter-layer animation", TestExtendedInterlayer),
        ("Extended 2: smooth scroll", test_extended_smooth_scroll),
        ("Dynamic sprites", test_dynamic_sprites),
        ("Speed", test_speed),
        ("Input 1: keyboard", test_keyboard),
        ("Input 2: mouse", test_mouse),
        ("Input 3: text input", test_text_input),
        ("Input 4: filtering", test_input_filtering),
        ("Window resizing", test_window_resize),
        ("Examining cell contents", test_pick)
    )

    reset()

    while True:
        blt.clear()
        for (i,e) in enumerate(entries):
            shortcut = '123456789abcdefghijklmnopqrstuvwxyz'[i]
            blt.puts(2, 1+i, "[color=orange]%c.[/color] %s%s" % (shortcut, "" if e[1] else "[color=gray]", e[0]))
            
        blt.puts(2, 23, "[color=orange]ESC.[/color] Exit")
        blt.refresh()

        key = blt.read()

        if key in (blt.TK_ESCAPE, blt.TK_CLOSE):
            break
        elif blt.TK_1 <= key <= blt.TK_9 or blt.TK_A <= key <= blt.TK_Z:
            index = key - blt.TK_1 if key >= blt.TK_1 else 9 + key - blt.TK_A
            if 0 <= index < len(entries) and entries[index][1]:
                entries[index][1]()
                reset()

    blt.close()
Exemple #29
0
def main():
    terminal.open()
    terminal.refresh()

    controller = Controller()
    player = Player(controller)
    hunger = Hunger(player)

    walls = [
        Wall(WALL_X, WALL_Y[0]),
        Wall(WALL_X, WALL_Y[1]),
        Wall(WALL_X, WALL_Y[2]),
    ]

    food_list = [
        Food(FOOD_X[0], FOOD_Y[0]),
        Food(FOOD_X[1], FOOD_Y[1]),
        Food(FOOD_X[2], FOOD_Y[2]),
    ]

    entities = [
        player,
        hunger,
    ]

    entities.extend(food_list)
    entities.extend(walls)

    updater = Updater(entities)
    collider = Collider(entities)
    render = Render(entities)

    while True:

        controller.update()

        if controller.is_exit:
            break

        if player.is_game_over:
            render_game_over()
        else:
            terminal.refresh()

            updater.update()
            collider.update()
            render.update()

    terminal.close()
Exemple #30
0
    def __init__(self, connection, vessel, program=None):
        self.vessel = vessel
        self.connection = connection
        self.program = program
        self.messages = deque(maxlen=5)

        terminal.open()
        terminal.set('window: size={}x{}'.format(
            len(templateStr[1]) + 2,
            len(templateStr) + 2))

        for i, line in enumerate(templateStr):
            terminal.printf(0, i, ' {} '.format(line))

        terminal.refresh()
Exemple #31
0
    def __init__(self):
        # Open terminal
        blt.open()
        blt.refresh()

        # Set up the terminal
        blt.set(
            "window: title='Roguelike', cellsize=12x12, resizeable=true, size=80x45, minimum-size=27x5; ini.settings.tile-size=16;"
        )

        # Create world
        self.world = World()
        start_pos = self.world.generate_floor()
        self.world.add_player(Player(start_pos, self.world))
        self.render()
Exemple #32
0
 def init_terminal(self):
     blt.open()
     blt.set(f"""window.size={TERMINAL_SIZE_X}x{TERMINAL_SIZE_Y},
                 window.cellsize={TERMINAL_CELL_SIZE_X}x{TERMINAL_CELL_SIZE_Y},
                 resizeable=true, minimum-size={TERMINAL_SIZE_X}x{TERMINAL_SIZE_Y}""")
     blt.set("font: res/fonts/VeraMono.ttf, size=12x24, spacing=1x1")
     blt.set("terrain font: res/tilesets/Curses_square_24.png, size=24x24, codepage=437, spacing=2x1")
     blt.set("U+E100: res/character/soldier_24.png, size=24x24")
     blt.set("U+E101: res/character/mercenary_24.png, size=24x24")
     blt.set("U+E102: res/character/echoes-map-skogul.png, size=32x32")
     blt.set("U+E103: res/character/echoes-map-spartan.png, size=32x32")
     blt.set("U+E104: res/character/echoes-map-conqueror.png, size=32x32")
     blt.set("window.title='SimplyRL'")
     blt.set("input.filter={keyboard, mouse+}")
     blt.composition(True)
     blt.refresh()
Exemple #33
0
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()