Exemplo n.º 1
0
    def lose(self):
        blt.clear()
        blt.set('window:size=60x20')
        blt.set('font: UbuntuMono-R.ttf, size=14')
        blt.print_(
            0, 0, """
A zombie blunders into you
and grasps your arm instinctively.
the smell of blood fills the air after one bite,
and as you black out you can almost
see the rest of the zombies
shambling towards their next meal.

You stacked {0} out of 10 corpses.

*** Press Escape to exit ***
*** Press R to restart ***

Stuck?
See FAQ.md for spoilers!
""".format(self.calculate_score()), blt.state(blt.TK_WIDTH),
            blt.state(blt.TK_HEIGHT), blt.TK_ALIGN_CENTER)
        blt.refresh()
        while True:
            kp = blt.read()
            if kp == blt.TK_R:
                self.restart = True
            if kp in [blt.TK_CLOSE, blt.TK_ESCAPE, blt.TK_R]:
                break
        self.stop = True
Exemplo n.º 2
0
def test_window_resize():
    blt.set(
        "window: title='Omni: window resizing', resizeable=true, minimum-size=27x5"
    )

    symbol = 0x2588

    while True:
        blt.clear()
        w = blt.state(blt.TK_WIDTH)
        h = blt.state(blt.TK_HEIGHT)
        for x in range(w):
            blt.put(x, 0, symbol if x % 2 else '#')
            blt.put(x, h - 1, symbol if x % 2 else '#')
        for y in range(h):
            blt.put(0, y, symbol if y % 2 else '#')
            blt.put(w - 1, y, symbol if y % 2 else '#')
        blt.puts(3, 2, "Terminal size is %dx%d" % (w, h))
        blt.refresh()

        key = blt.read()

        if key in (blt.TK_CLOSE, blt.TK_ESCAPE):
            break

    blt.set("window: resizeable=false")
Exemplo n.º 3
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()
Exemplo n.º 4
0
    def make_minimap():

        minimap = np.ones_like(game_map.tiles, dtype=int)
        for x in range(game_map.width):
            for y in range(game_map.height):
                minimap[y][x] = blt.color_from_name("dark gray")
                if len(game_map.tiles[x][y].entities_on_tile) > 0:
                    if game_map.tiles[x][y].entities_on_tile[
                            -1].name == "tree":
                        minimap[y][x] = blt.color_from_name("dark green")
                    elif "wall" in game_map.tiles[x][y].entities_on_tile[
                            -1].name:
                        minimap[y][x] = blt.color_from_name("dark amber")
                    elif game_map.tiles[x][y].entities_on_tile[
                            -1].name == "player":
                        minimap[y][x] = blt.color_from_name(None)
                    elif game_map.tiles[x][y].entities_on_tile[-1].fighter \
                            and game_map.tiles[x][y].entities_on_tile[-1].name != "player":
                        minimap[y][x] = blt.color_from_name("light red")
                    else:
                        minimap[y][x] = blt.color_from_name("light gray")
                elif game_map.tiles[x][y].blocked:
                    minimap[y][x] = blt.color_from_name("light gray")
                # if not game_map.tiles[x][y].explored:
                #     minimap[y][x] = blt.color_from_name("#000000")

        minimap = minimap.flatten()
        minimap = (c_uint32 * len(minimap))(*minimap)
        blt.set(
            "U+F900: %d, raw-size=%dx%d, resize=%dx%d, resize-filter=nearest" %
            (addressof(minimap), game_map.width, game_map.height, 500, 500))
Exemplo n.º 5
0
 def load_sprites(self):
     if not self.options.graphical_tiles:
         return
     
     for char, sprite_name in sprite_chars:
         sprite_path = os.path.join(config.graphics_folder, sprite_name)
         terminal.set("{}: {}, size=16x16, spacing=2x1;".format(char, sprite_path))
Exemplo n.º 6
0
    def terminal_init(self):
        super().terminal_init()

        config = get_blt_config()
        print("CONFIG:")
        print(config)
        terminal.set(config)
Exemplo n.º 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")
Exemplo n.º 8
0
def mainloop():
    #main values
    closed = False
    gameType = 0  # 0 - default/ 1 - fight/ 2 - inventory/ 3 - map/ 4 - dialogue/6/7/8/9
    debug_value = 0
    debug_string = (" debug")
    screen_width = 120
    screen_height = 40
    BASE_damage = 5
    #player values
    map_x = 0
    map_y = 0
    player_infight = False
    player_alive = True
    player_lvl = 1
    player_EXP = 0
    player_stat1 = 5
    player_stat2 = 5
    player_stat3 = 5
    blt.set("window.title='pythonRPG'")
    blt.clear()
    blt.color("white")
    debug_view = ("[color=orange]Debug string:" + debug_string + "[/color]]"
                  )  #make string in puts rather than
    blt.puts(2, 3, debug_view)  #create another variable
    blt.refresh()
    while closed == False:
        blt.refresh()
Exemplo n.º 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()
Exemplo n.º 10
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
Exemplo n.º 11
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()
Exemplo n.º 12
0
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
Exemplo n.º 13
0
def scene():

    blt.set(f"window.title=' {textutils.lucynest} help'")

    width = blt.state(blt.TK_WIDTH)
    height = blt.state(blt.TK_HEIGHT)

    info = "Manual..."

    while True:
        blt.clear()

        blt.puts(0, 1, "Help", width, 1, blt.TK_ALIGN_CENTER)

        blt.puts(0, 0, utils.multiline_trim(info), width, line - 2,
                 bltutils.align_center)

        blt.puts(0, line - 2, "Keybindings", width, line - 2,
                 blt.TK_ALIGN_CENTER)
        keybindings()

        blt.puts(2, height - 2, utils.button_quit())

        blt.refresh()

        key = blt.read()
        if key in (blt.TK_ESCAPE, blt.TK_CLOSE):
            break
Exemplo n.º 14
0
def prepare_terminal():
    running = terminal.open()
    if running:
        terminal.set("window: size=%sx%s, title=%s, cellsize=%s" %
                     (screen_info.screen_width, screen_info.screen_height,
                      screen_info.title, screen_info.cellsize))
    else:
        raise Exception("Terminal could not open.")
Exemplo n.º 15
0
def test_auto_generated():
    blt.set("window.title='Omni: auto-generated tileset'")

    hoffset = 40
    cell_width = blt.state(blt.TK_CELL_WIDTH)
    cell_height = blt.state(blt.TK_CELL_HEIGHT)

    def setup_cellsize():
        blt.set("window.cellsize=%dx%d" % (cell_width, cell_height))

    while True:
        blt.clear()
        blt.color("white")

        blt.puts(
            2, 1, "[color=orange]Cell size:[/color] %dx%d" %
            (cell_width, cell_height))
        blt.puts(
            2, 3,
            "[color=orange]TIP:[/color] Use arrow keys\nto change cell size")

        for j in range(16):
            blt.puts(hoffset + 6 + j * 2, 1, "[color=orange]%X" % j)

        y = 0
        for code in range(0x2500, 0x259F + 1):
            if code % 16 == 0:
                blt.puts(hoffset, 2 + y * 1, " [color=orange]%04X" % code)

            blt.put(hoffset + 6 + (code % 16) * 2, 2 + y * 1, code)

            if (code + 1) % 16 == 0: y += 1

        blt.puts(
            2, 6, u"┌─┐┌─┐┌─┐┌─┐┌─┐┌─┐┌─┐┌─┐┌─┐\n"
            u"│Z││A││ ││W││A││R││U││D││O│\n"
            u"└─┘└─┘└─┘└─┘└─┘└─┘└─┘└─┘└─┘\n")

        blt.refresh()

        key = blt.read()

        if key in (blt.TK_CLOSE, blt.TK_ESCAPE):
            break
        elif key == blt.TK_LEFT and cell_width > 4:
            cell_width -= 1
            setup_cellsize()
        elif key == blt.TK_RIGHT and cell_width < 24:
            cell_width += 1
            setup_cellsize()
        elif key == blt.TK_DOWN and cell_height < 24:
            cell_height += 1
            setup_cellsize()
        elif key == blt.TK_UP and cell_height > 4:
            cell_height -= 1
            setup_cellsize()

    blt.set("window.cellsize=auto")
Exemplo n.º 16
0
    def apply_input_filter():
        ss = ""
        for event in events:
            if event[1] == 0: continue  # disabled
            ss += event[0]  # keypress
            if event[1] == 2: ss += "+"  # keyrelease too
            ss += ", "

        blt.set("input.filter={%s}" % ss)
Exemplo n.º 17
0
def test_text_input():
    blt.set("window.title='Omni: text input'")
    blt.composition(False)

    max_chars = 32
    text = ""
    character = ' '
    result = 0
    char_result = 0

    while True:
        blt.clear()
        blt.color("white")

        blt.puts(2, 1, "Select different input tests by pressing corresponding number:")

        blt.puts(2, 3, "[color=orange]1.[/color] read_str")
        draw_frame(5, 4, max_chars + 2, 3)
        blt.puts(6, 5, "%s" % text)
        blt.puts(5 + max_chars + 2 + 1, 5, "[color=gray] %s" % ("OK" if result >= 0 else "Cancelled"))

        blt.puts(2, 8, "[color=orange]2.[/color] read_char")
        draw_frame(5, 9, 5, 3)
        blt.put(7, 10, character)
        blt.puts(11, 10, "[color=gray]%s" % key_names.get(char_result, str(char_result)))

        blt.refresh()

        key = blt.read()
        if key in (blt.TK_CLOSE, blt.TK_ESCAPE):
            break

        elif key == blt.TK_1:
            blt.color("orange")
            draw_frame(5, 4, max_chars + 2, 3)
            result, text = blt.read_str(6, 5, text, max_chars)

        elif key == blt.TK_2:
            blt.color("orange")
            draw_frame(5, 9, 5, 3)

            while True:
                blt.put(7, 10, character)  
                blt.clear_area(11, 10, 16, 1)
                blt.puts(11, 10, "[color=gray]%s" % key_names.get(char_result, str(char_result)))
                blt.refresh()

                character = ' '
                key = blt.read()
                if key in (blt.TK_ESCAPE, blt.TK_CLOSE, blt.TK_RETURN):
                    break
                elif blt.check(blt.TK_WCHAR):
                    character = blt.state(blt.TK_WCHAR)
                    char_result = key
                elif key < blt.TK_KEY_RELEASED:
                    char_result = key
Exemplo n.º 18
0
def scene():
    blt.set(f"window.title='{textutils.lucynest}: in a dream'")

    world = World()

    width = blt.state(blt.TK_WIDTH)
    height = blt.state(blt.TK_HEIGHT)
    parts = 6
    left = width // 6
    right = width * (parts - 1) // parts
    middle = height // 2
    padding = 1

    story = [
        "Hi! I'm Avatar, actually me is who You are in this World",
        "Lets find out what we've got here in lucid dream",
        "Open Your mind and enter this evershining mental landscape",
    ]
    story_point = 0
    while True:
        blt.clear()

        blt.color("light gray")
        for y in range(height - 1):
            blt.put(left, y, bltutils.box_upper_half)
            blt.put(right, y, bltutils.box_upper_half)
        for x in range(left + 1, right):
            blt.put(x, middle, bltutils.box_whole)

        blt.color("white")
        # blt.put_ext(view_width * 4 + 1, 0, margin, margin, 0xE100)
        avatar_symbol = "@:"
        left_avatar = left + 1 + padding
        left_avatar_text = left_avatar + len(avatar_symbol) + 1

        blt.puts(left_avatar, middle // 5,
                 bltutils.colored(avatar_symbol, "orange"))
        blt.puts(left_avatar_text, middle // 5, story[story_point],
                 right - 1 - padding - left_avatar_text,
                 middle - 1 - padding - middle // 5, blt.TK_ALIGN_LEFT)

        line = 1
        for element in world.avatar.elements:
            blt.puts(
                0, line,
                bltutils.colored(element.scale.current_value, element.name))
            line += 1

        blt.refresh()

        key = blt.read()

        if key in (blt.TK_CLOSE, blt.TK_ESCAPE):
            break
        elif key == blt.TK_ENTER:
            story_point += 1 if story_point < len(story) - 1 else 0
Exemplo n.º 19
0
 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)
Exemplo n.º 20
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()
Exemplo n.º 21
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()
Exemplo n.º 22
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
Exemplo n.º 23
0
    def window_actions(self, fullscreen=False, close=False):
        if fullscreen:
            blt.set("window.fullscreen=true")
            self.owner.fov_recompute = True
            return True

        if close:
            blt.close()

        return False
Exemplo n.º 24
0
    def __init__(self, main):
        self.main = main
        self.quit = False
        self.debug = False
        self.pause = False
        self.slow = False
        self.help = 0
        self.activePanel = None
        self.activeButton = None

        term.set("input: filter=[keyboard,mouse];")
Exemplo n.º 25
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')
Exemplo n.º 26
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()
Exemplo n.º 27
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()
Exemplo n.º 28
0
def debug_render(player, current_map):
    # Full map render with no FOV and smaller cell size for testing purposes.
    terminal.set("window: size='100x80', cellsize='16x16'")
    for x in range(100):
        for y in range(80):
            tile = current_map.tiles[x][y]
            current_map.tiles[x][y].draw(
                x, y, dim_argb(tile.color_fg,
                               player.distance_to(tile) * 25),
                dim_argb(tile.color_bg,
                         player.distance_to(tile) * 25))
        player.draw(player.x, player.y,
                    current_map.tiles[player.x][player.y].color_bg)
Exemplo n.º 29
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()
Exemplo n.º 30
0
def menu(header, options, width):
    if len(options) > 26:
        raise ValueError('Cannot have a menu with more than 26 options.')
    header_text = textwrap.wrap(header, width)
    header_height = len(header_text)
    if header == '':
        header_height = 0
    height = len(options) + header_height

    # top left corner of menu
    x = var.SCREEN_WIDTH / 2 - width / 2
    y = var.SCREEN_HEIGHT / 2 - height / 2

    terminal.color(terminal.color_from_name('white'))
    terminal.bkcolor(terminal.color_from_name('transparent'))
    y_location = 0
    letter_index = ord('a')
    for line in header_text:
        terminal.printf(x, y + y_location, line)
        y_location += 1
    for option_text in options:
        text = '(' + chr(letter_index) + ')' + option_text
        terminal.printf(x, y + y_location, text)
        y_location += 1
        letter_index += 1
    terminal.refresh()

    key = terminal.read()

    # if key == terminal.TK_MOUSE_LEFT:
    #     (menu_x, menu_y) = (terminal.state(terminal.TK_MOUSE_X), terminal.state(terminal.TK_MOUSE_Y))
    #     # check if click is within the menu and on a choice
    #     if menu_x >= x and menu_x < x + width and menu_y >= y + header_height and menu_y < y + height - header_height:
    #         return menu_y
    #
    # if key == terminal.TK_MOUSE_RIGHT or key == terminal.TK_ESCAPE:
    #     return None # cancel if the player right-clicked or pressed escape
    if key == terminal.TK_ENTER and terminal.check(terminal.TK_ALT):
        # alt+enter changes fullscreen
        fullscreen = terminal.check(terminal.TK_FULLSCREEN)
        fullscreen = not fullscreen
        terminal.set('window.fullscreen=' + fullscreen)

    if terminal.check(terminal.TK_WCHAR):
        index = terminal.state(terminal.TK_WCHAR) - ord('a')
        if index >= 0 and index < len(options):
            return index
        return None

    terminal.clear()
    return None
Exemplo n.º 31
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
Exemplo n.º 32
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()
Exemplo n.º 33
0
def test_basic_output():
    blt.set("window.title='Omni: basic output'")
    blt.clear()
    blt.color("white")

    # Wide color range
    n = blt.print_(2, 1, "[color=orange]1.[/color] Wide color range: ")
    long_word = "antidisestablishmentarianism."
    long_word_length = len(long_word)
    for i in range(long_word_length):
        factor = i / long_word_length
        red = int((1 - factor) * 255)
        green = int(factor * 255)
        blt.color(blt.color_from_argb(255, red, green, 0))
        blt.put(2 + n + i, 1, long_word[i])

    blt.color("white")

    blt.print_(2, 3, "[color=orange]2.[/color] Backgrounds: [color=black][bkcolor=gray] grey [/bkcolor] [bkcolor=red] red ")

    blt.print_(2, 5, "[color=orange]3.[/color] Unicode support: Кириллица Ελληνικά α=β²±2°")

    blt.print_(2, 7, "[color=orange]4.[/color] Tile composition: @ + [color=red]|[/color] = @[+][color=red]|[/color], a vs. ¨ a[+][color=red]¨[/color]")

    blt.printf(2, 9, "[color=orange]5.[/color] Box drawing symbols:")

    blt.print_(5, 11,
        "   ┌────────┐  \n"
        "   │!......s└─┐\n"
        "┌──┘........s.│\n"
        "│............>│\n"
        "│...........┌─┘\n"
        "│<.@..┌─────┘  \n"
        "└─────┘  ■█┘╙       \n"
    )





    blt.refresh()
    key = None
    while key not in (blt.TK_CLOSE, blt.TK_ESCAPE):
        key = blt.read()
Exemplo n.º 34
0
def test_tilesets():
    blt.set("window.title='Omni: tilesets'")
    blt.composition(True)

    # Load tilesets
    blt.set("U+E100: ./Images/Runic.png, size=8x16")
    blt.set("U+E200: ./Images/Tiles.png, size=32x32, align=top-left")
    blt.set("U+E400: ./Images/test_tiles.png, size=16x16, align=top-left")
    blt.set("U+E300: ./Fonts/fontawesome-webfont.ttf, size=24x24, spacing=3x2, codepage=./Fonts/fontawesome-codepage.txt")
    blt.set("zodiac font: ./Fonts/Zodiac-S.ttf, size=24x36, spacing=3x3, codepage=437")

    blt.clear()
    blt.color("white")

    blt.print_(2, 1, "[color=orange]1.[/color] Of course, there is default font tileset.")

    blt.print_(2, 3, "[color=orange]2.[/color] You can load some arbitrary tiles and use them as glyphs:")
    blt.print_(2+3, 4,
        "Fire rune ([color=red][U+E102][/color]), "
        "water rune ([color=lighter blue][U+E103][/color]), "
        "earth rune ([color=darker green][U+E104][/color])")

    blt.print_(2, 6, "[color=orange]3.[/color] Tiles are not required to be of the same size as font symbols:")
    blt.put(2+3+0, 7, 0xE200+7)
    blt.put(2+3+5, 7, 0xE200+8)
    blt.put(2+3+10, 7, 0xE200+9)

    blt.print_(2, 10, "[color=orange]4.[/color] Like font characters, tiles may be freely colored and combined:")

    blt.put_ext(2+3+0, 11, 0, 0, tiles['stone_wall'], [blt.color_from_name("red"),
                                                       blt.color_from_name("red"),
                                                       blt.color_from_name("blue"),
                                                       blt.color_from_name("red")])
    blt.put_ext(2 + 3 + 2, 11, 0, 0, tiles['stone_wall'], [blt.color_from_name("red"),
                                                           blt.color_from_name("blue"),
                                                           blt.color_from_name("red"),
                                                           blt.color_from_name("red")])
    blt.put_ext(2 + 3 + 0, 13, 0, 0, tiles['stone_wall'], [blt.color_from_name("red"),
                                                           blt.color_from_name("red"),
                                                           blt.color_from_name("blue"),
                                                           blt.color_from_name("blue")])
    blt.put_ext(2 + 3 + 2, 13, 0, 0, tiles['stone_wall'], [blt.color_from_name("blue"),
                                                           blt.color_from_name("blue"),
                                                           blt.color_from_name("red"),
                                                           blt.color_from_name("red")])

    blt.put_ext(2 + 3 + 0 + 5, 11, 0, 0, '#', [blt.color_from_name("yellow"),
                                                           blt.color_from_name("black"),
                                                           blt.color_from_name("black"),
                                                           blt.color_from_name("black")])
    blt.put_ext(2 + 3 + 1 + 5, 11, 0, 0, 'A', [blt.color_from_name("black"),
                                                           blt.color_from_name("yellow"),
                                                           blt.color_from_name("yellow"),
                                                           blt.color_from_name("black")])
    blt.put_ext(2 + 3 + 0 + 5, 12, 0, 0, 'A', [blt.color_from_name("black"),
                                                           blt.color_from_name("black"),
                                                           blt.color_from_name("yellow"),
                                                           blt.color_from_name("yellow")])
    blt.put_ext(2 + 3 + 1 + 5, 12, 0, 0,'@', [blt.color_from_name("dark yellow"),
                                                           blt.color_from_name("dark yellow"),
                                                           blt.color_from_name("dark yellow"),
                                                           blt.color_from_name("dark yellow")])

    blt.put_ext(2 + 3 + 0 + 7, 11, 0, 0, 'A', [blt.color_from_name("black"),
                                               blt.color_from_name("yellow"),
                                               blt.color_from_name("black"),
                                               blt.color_from_name("black")])

    blt.put_ext(2 + 3 + 0 + 7, 12, 0, 0, 'A', [blt.color_from_name("yellow"),
                                               blt.color_from_name("yellow"),
                                               blt.color_from_name("black"),
                                               blt.color_from_name("black")])


    '''
    # blt.color("lightest red")
    blt.put(2+3+4, 11,tiles['stairs'])
    # blt.color("purple")
    blt.put(2+3+8, 11, tiles['gold'])
    #blt.color("darkest red")
    blt.put(17, 11, 0xE400+0)
    blt.put(18, 11, 0xE400+0)
    blt.put(19, 11, 0xE400+1)
    blt.put(20, 11, 0xE400 + 0)
    blt.put(20, 11, 0xE400 + 2)

    blt.put(17, 12, 0xE400 + 10)
    blt.put(18, 12, 0xE400 + 10)
    blt.put(19, 12, 0xE400 + 11)
    blt.put(20, 12, 0xE400 + 10)
    blt.put(20, 12, 0xE400 + 12)
    '''
    blt.put(21, 11, 0xE400+0)
    blt.color("blue")
    blt.put(18, 11, '@')

    blt.color("white")
    order = [11, 10, 14, 12, 13]
    for i in range(len(order)):
        blt.put(30 + i * 4, 11, 0xE200 + order[i]);
        blt.put(30 + (len(order)+1) * 4, 11, 0xE200 + order[i])

    blt.put(30 + len(order) * 4, 11, 0xE200 + 15)

    blt.print_(2, 15, "[color=orange]5.[/color] And tiles can even come from TrueType fonts like this:")
    for i in range(6):
        blt.put(5 + i * 5, 15, 0xE300 + i)

    blt.print_(5, 18, "...or like this:\n[font=zodiac]D F G S C")

    blt.refresh()

    key = None
    while key not in (blt.TK_CLOSE, blt.TK_ESCAPE):
        key = blt.read()

    # Clean up
    blt.set("U+E100: none; U+E200: none; U+E300: none; zodiac font: none")
    blt.composition(False)