예제 #1
0
def _render_room(blueprint, openings, room, conjunction_point):
    # Draw the currently pending room
    blt.clear()
    room.render(ANIMATION_RENDERER)
    blt.bkcolor(colors.CLEAR)
    blt.refresh()
    time.sleep(ANIMATION_FRAME_LENGTH / 1000)

    # If it was added successfully, show the world with its new addition.
    if conjunction_point is not None:
        blt.clear()

        ANIMATION_CAMERA.move_to(conjunction_point[0], conjunction_point[1])
        ANIMATION_RENDERER.transform(ANIMATION_CAMERA)

        for y in range(len(blueprint)):
            for x in range(len(blueprint[0])):
                blueprint[y][x].render(x, y, ANIMATION_RENDERER)

        for (x, y) in openings:
            ANIMATION_RENDERER.render(
                x, y, Symbol(' ', blt.color_from_name("white")), 0,
                colors.WORLD_GEN_OPENING)
        blt.bkcolor(colors.CLEAR)
        blt.refresh()
        time.sleep(ANIMATION_FRAME_LENGTH / 1000)

        ANIMATION_CAMERA.move_to(0, 0)
        ANIMATION_RENDERER.transform(ANIMATION_CAMERA)
예제 #2
0
 def run_loop_iteration(self):
     while terminal.has_input():
         char = terminal.read()
         self.terminal_read(char)
     should_continue = self.terminal_update()
     terminal.refresh()
     return should_continue
예제 #3
0
def render_ui():
    # Input.update()
    ui()
    objects()
    # update()
    # libtcod.console_flush()
    terminal.refresh()
예제 #4
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
예제 #5
0
파일: game.py 프로젝트: ltouroumov/yarl
    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()
예제 #6
0
파일: bltrl.py 프로젝트: dbaker84/RL2
def DrawProjectile(points):
    blt.layer(251)
    render_all(entities, gamemap)
    lx = -1
    ly = -1

    for i in range(0, len(points) - 1):
        blt.puts(points[i][0], points[i][1], "[color=cyan]*[/color]")
        if lx >= 0:
            blt.puts(lx, ly, "[color=black] [/color]")
            blt.clear_area(lx, ly, 1, 1)
            blt.refresh()
        lx = points[i][0]
        ly = points[i][1]

        blt.refresh()

    # for i in range(0, len(px) - 1):
    #     blt.puts(int(px[i]), int(py[i]), "[color=cyan]*[/color]")
    #     if lx >= 0:
    #         blt.puts(lx, ly, "[color=black] [/color]")
    #         blt.clear_area(lx, ly, 1, 1)
    #         blt.refresh()
    #         lx = px[i]
    #         ly = py[i]
    #     blt.refresh()
    blt.clear()
예제 #7
0
    def update(self):
        if self.owner:
            layer = self.owner.layer
            x = self.owner.pos.x
            y = self.owner.pos.y
        else:
            layer = terminal.state(terminal.TK_LAYER)
            x = 0
            y = 0

        if mouse.clicked_rect(self.x + x, self.y + y, self.length, 1):
            terminal.layer(layer)
            terminal.color('white')
            terminal.puts(self.x + 1 + x, self.y + y,
                          self.skin['BACKGROUND'] * self.length)
            terminal.color('black')
            terminal.refresh()
            result, text = terminal.read_str(self.x + x + 1, self.y + y,
                                             self.text, self.length)
            terminal.refresh()
            self.text = text
            self.updated = True

            self.active = True
            self.dirty = True
예제 #8
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()
예제 #9
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()
예제 #10
0
def ui_print(terminal, x, y, h, w, text_string):

    terminal.layer(UI_LAYER)
    terminal.clear_area(dialog_pos_x, dialog_pos_y, dialog_width,
                        dialog_height)
    terminal.printf(dialog_pos_x, dialog_pos_y, ml.get_scroll_back())
    terminal.refresh()
예제 #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()
예제 #12
0
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()
예제 #13
0
파일: layers.py 프로젝트: phomm/blt_samples
def test_layers():
    blt.set("window.title='Omni: layers'")

    pixel = c_uint32(blt.color_from_name("dark gray"))

    blt.set("U+E000: %d, raw-size=1x1, resize=48x48, resize-filter=nearest" % addressof(pixel))

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

    blt.puts(2, 1, "[color=orange]1.[/color] Without layers:")
    blt.put(7, 3, 0xE000)   
    blt.puts(5, 4, "[color=dark green]abcdefghij")

    blt.puts(2, 8, "[color=orange]2.[/color] With layers:")
    blt.layer(1)
    blt.put(7, 10, 0xE000)
    blt.layer(0)
    blt.puts(5, 11, "[color=dark green]abcdefghij")

    blt.refresh()

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

    blt.set("U+E000: none")
예제 #14
0
 def open_menu(self, menu):
     blt.layer(RenderLayer.BACKGROUND.value)
     blt.clear()
     blt.layer(RenderLayer.MENU.value)
     blt.clear()
     blt.refresh()
     self.current_menu = menu
예제 #15
0
파일: draw.py 프로젝트: adael/goldminer
def draw_menu_option_state(lst):
    terminal.clear_area(30, 14, 60, 30)
    terminal.color("yellow")
    terminal.print_(30, 14, "Screen size")
    draw_double_line(30, 15, len("Screen size"))
    draw_select_box(lst, 30, 16)
    terminal.refresh()
예제 #16
0
 def draw(self):
     terminal.clear()
     self.world.draw()
     self.player.draw()
     self.gui.draw()
     self.info.draw()
     terminal.refresh()
예제 #17
0
파일: newgame.py 프로젝트: Cerepol/unnamed
	def render(self):
		if splash:
			t.layer(0)
			set_colour(colours.white, 100)
			t.put(0, 0, 0x5E)
			#show the game's title, and some credits!

			
			title = 'Death and Axes'
			center = (SCREEN_WIDTH - len(title)) // 2

			t.layer(UI_LAYER)
			set_colour(colours.dark_azure, 150)
			t.puts(center - 1, SCREEN_HEIGHT//2 - 5, BLOCK_CHAR * (len(title) + 2) * 3, len(title) + 2, 3)

			t.layer(UI_TEXT_LAYER)
			set_colour(colours.light_yellow)
			t.puts(center, SCREEN_HEIGHT//2-4, title)

			title = 'By Cerepol'
			center = (SCREEN_WIDTH - len(title)) // 2

			t.layer(UI_LAYER)
			set_colour(colours.dark_azure, 150)
			t.puts(center - 1, SCREEN_HEIGHT - 3, BLOCK_CHAR * (len(title) + 2) * 3, len(title) + 2, 3)

			t.layer(UI_TEXT_LAYER)
			set_colour(colours.light_yellow)
			t.puts(center, SCREEN_HEIGHT-2, title)

			t.refresh()
			t.delay(2000)
			t.layer(0)

			splash = False
예제 #18
0
파일: main.py 프로젝트: caretop/partyRL
def game_main_loop():
    game_quit = False

    while not game_quit:

        # clear
        blt.clear()

        # draw game
        draw_game()

        # refresh term
        blt.refresh()

        # avoid blocking the game with blt.read
        while not game_quit and blt.has_input():
            player_action = game_handle_keys()

            map_calculate_fov()

            if player_action == "QUIT":
                game_quit = True

            # let the AIs take action
            if player_action != "no-action" and player_action != "mouse_click":
                for ent in GAME.current_entities:
                    if ent.ai:
                        ent.ai.take_turn()

    # save game
    save_game()

    # quit the game
    blt.close()
예제 #19
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")
예제 #20
0
    def add_scoped_message(self,
                           message_actor=None,
                           message_target=None,
                           message_others=None,
                           show_now=False,
                           scope=MessageScope.TargetsPlayer,
                           actor=None,
                           target=None,
                           targets=None):

        if targets is None:
            targets = self._no_targets

        in_scope = self._check_scope(scope, actor, target, targets)
        if not in_scope:
            return

        player = self.game.player
        if actor is player:
            self.messages.append(message_actor)
        elif target is player or player in targets:
            self.messages.append(message_target)
        else:
            self.messages.append(message_others)

        if show_now:
            self.game.scene.update_messages()
            terminal.refresh()
예제 #21
0
    def render_menu(self):
        print(f'Menu: Render menu: i am {self}')
        terminal.layer(Layers.MENU.value)

        window_width = 0
        window_height = 0
        for content in self.menu_contents:
            content_width = content.get_total_width()
            if content_width > window_width:
                window_width = content_width
            window_height += content.get_total_height()
        x1, y1 = self.menu_placement(window_width, window_height)

        draw_background(x1 - 1,
                        y1 - 1,
                        x1 + window_width + 2,
                        y1 + window_height + 1,
                        color='gray')
        self.menu_contents = sorted(self.menu_contents,
                                    key=lambda cont: cont.render_order)
        for content in self.menu_contents:
            y1 += content.margin
            content.paste_on_window(x1, y1, window_width)
            y1 += content.get_height()
            y1 += content.linebreak
            y1 += content.margin

        terminal.refresh()
예제 #22
0
    def update(self):
        if self.owner:
            layer = self.owner.layer
            x = self.owner.pos.x
            y = self.owner.pos.y
        else:
            layer = terminal.state(terminal.TK_LAYER)
            x = 0
            y = 0

        if mouse.clicked_rect(self.x + x, self.y + y, self.length, 1):
            terminal.layer(layer)
            terminal.color('white')
            terminal.puts(self.x + 1 + x, self.y + y,
                          self.skin['BACKGROUND'] * self.length)
            terminal.color('black')
            terminal.refresh()
            result, text = terminal.read_str(self.x + x + 1, self.y + y,
                                             self.text, self.length)
            terminal.refresh()
            if text.isnumeric() and (self.min_val <= int(text) <=
                                     self.max_val):
                self.text = str(text)
                self.error = None
                self.updated = True
            else:
                self.error = 'Text must be numeric and between ' + str(
                    self.min_val) + ' and ' + str(self.max_val) + '.'

            self.active = True
            self.dirty = True
예제 #23
0
    def pprint_center(self, text: List[str]):
        """
        Prints a string or list of strings in the center of the window

        :param text: List of strings to be printed
        """
        height = self.window.height
        width = self.window.width
        cellsize, _ = self.window.cell_size.split('x')
        cell_width = int(cellsize)
        center = int(width / 2)

        bearlib.clear()
        bearlib.layer(1)
        bearlib.composition("TK_ON")
        y = int(height / 2 - len(text) / 2)
        for i, s in enumerate(text):
            middle_char = int(len(s) / 2)
            x = int(center - middle_char)
            pos = 0
            for c in s:
                offset = (center - x) * (cell_width / 2)
                bearlib.put_ext(x, y + i, int(offset), 0, c)
                x = x + 1
                pos = pos + 1
        bearlib.composition("TK_OFF")
        bearlib.layer(0)
        bearlib.refresh()
예제 #24
0
 def make_sector(main, depth, height, width):
     terminal.printf(main.center_text('Scanning sector...'), 12,
                     'Scanning sector...')
     loading = int(main.window_center - depth / 2)
     center = [int(depth / 2), int(height / 2), int(width / 2)]
     map_layer = []
     for z in range(depth):
         map_height = []
         for y in range(height):
             map_width = []
             for x in range(width):
                 tile = Object()
                 chance = random.randrange(0, 10000)
                 if chance < 9800:
                     NewTile.empty_space(tile)
                 elif chance < 9995:
                     NewTile.add_dust(tile)
                 else:
                     NewTile.add_sun(tile)
                 map_width.append(tile)
             map_height.append(map_width)
         terminal.printf(loading + z, 14, 'Рюд')
         terminal.refresh()
         map_layer.append(map_height)
     # test of generating a central sun for the solar_system generator
     MapGen.add_sun(map_layer, center[0], center[1], center[2], 16,
                    MapGen.rand_color(), MapGen.rand_color())
     MapGen.add_planet(map_layer, center[0] + 24, center[1] + 24, center[2],
                       5, MapGen.rand_color(), MapGen.rand_color())
     print('map generated')
     terminal.printf(main.center_text('Map Generated'), 3, 'Map Generated!')
     terminal.refresh()
     return (map_layer)
예제 #25
0
    def refresh(self):
        """
        Refresh a terminal.

        Actually draws whatever changes were made by ``*_widget`` methods.
        """
        terminal.refresh()
예제 #26
0
    def draw(self):
        terminal.clear()

        self.tree.draw()
        for ui_element in self.ui_elements:
            ui_element.draw()
        terminal.refresh()
예제 #27
0
    def exit_window(self):
        # Menus in game
        if self.app_states == AppStates.GAME:
            if self.game.target_mode:
                self.game.quit_target_mode()

            # Si pas de menu, on propose de quitter
            elif not self.game.current_menu:
                self.game.current_menu = QuitMenu(self)
            # Si menu, avec back to main quand on exit
            elif self.game.current_menu.back_to_main:
                self.app_states = AppStates.MAIN_MENU
                self.current_menu = MainMenu(self)
                self.game.close_menu()
            else:
                # on quitte le menu actuel pour revenir au jeu
                self.game.close_menu()

        elif self.app_states == AppStates.MAIN_MENU:
            # Je suis dans le main menu, je quitte l'appli
            if isinstance(self.current_menu, MainMenu):
                self.quit_app = True
            else:
                self.current_menu = MainMenu(self)
        blt.clear()
        blt.refresh()
예제 #28
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
예제 #29
0
파일: draw.py 프로젝트: adael/goldminer
def draw_view_item_window(lst, item: Item):
    rect = Rect.from_rect(settings.gui_rect)
    draw_window(rect, item.description, colors.white,
                colors.inventory_bk_color)
    terminal.bkcolor(colors.inventory_bk_color)
    draw_select_box(lst, rect.x + 1, rect.y + 3)
    terminal.refresh()
예제 #30
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
예제 #31
0
 def main_game_loop(self):
     blt.clear()
     self.render_map()
     self.render_entities()
     self.ecs.update()
     self.render_panel()
     blt.refresh()
예제 #32
0
def menu(header, options, width, screen_width, screen_height, title=None):
    if len(options) > 26:
        raise ValueError('Cannot have a menu with more than 26 options.')

    menu_x = int((screen_width - width) / 2)

    header_wrapped = textwrap.wrap(header, width)
    header_height = len(header_wrapped)

    menu_h = int(header_height + 1 + 26)
    menu_y = int((screen_height - menu_h) / 2)

    create_window(menu_x, menu_y, width, menu_h, title)

    for i, line in enumerate(header_wrapped):
        blt.puts(menu_x + 1, menu_y + 1 + i, header_wrapped[i])

    y = menu_y + header_height + 1
    letter_index = ord('a')
    for option_text in options:
        text = '(' + chr(letter_index) + ')' + option_text
        blt.puts(menu_x + 1, y, text)
        y += 1
        letter_index += 1
    blt.refresh()
예제 #33
0
def render_animations(animation_list):
    Render.clear_layer(10)
    for ani in animation_list:
        # print "Animating................."
        result = ani.play()
        if result == 'Done':
            # print "Want?"
            animation_list.remove(ani)
        terminal.refresh()
예제 #34
0
def render_all():
    # Fov.require_recompute()

    full_map()

    objects()

    ui()

    terminal.refresh()
예제 #35
0
파일: terminal.py 프로젝트: ltouroumov/yarl
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()
예제 #36
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()
예제 #37
0
def follow_line(source, target, projectile='-', end_tile='*', color=libtcod.yellow):

    if Constants.ANIMATE_ON:
        line = Utils.get_line((source.x, source.y), (target.x, target.y))
        for loc in line:
            Render.clear_layer(Render.layers['animation_console'])
            map_x, map_y = loc

            GameState.render_all()

            x, y = Utils.to_camera_coordinates(map_x, map_y)

            if (x, y) == line[-1]:
                Render.draw_char(Render.layers['animation_console'], x, y, end_tile, color)

            else:
                Render.draw_char(Render.layers['animation_console'], x, y, projectile, color)

            terminal.refresh()
            # time.sleep(0.01325) # 0.01325
        Render.clear_layer(Render.layers['animation_console'])
예제 #38
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)
예제 #39
0
def render_ui():
    UI.draw_hud()
    Animation.render_animations(animation_queue)
    terminal.refresh()
예제 #40
0
def display_mainMenu():
    # new_game()

    width = Constants.SCREEN_WIDTH
    height = Constants.SCREEN_HEIGHT

    Render.draw_rect(10, 0, 0, width, height,
                     frame=True,
                     f_color=Color('dark azure'),
                     bk_color=Color('darkest azure'),
                     title="DEEP FRIED SUPERNOVA v0.01")

    Render.print_rect(10, 4, 4, width, height, 'Welcome to Deep Fried Supernova')


    # blit the contents of "window" to the root console
    x = 0
    y = 0


    button_text = 'New Game'
    ng_button = Button(button_text,
                       width / 2,
                       height - 12,
                       length=16,
                       function=new_game,
                       target=10)

    button_text = 'Continue Game'
    ct_button = Button(button_text,
                       width / 2,
                       height - 9,
                       length=16,
                       function=continue_game,
                       target=10)

    button_text = 'Quit'
    qt_button = Button(button_text,
                       width / 2,
                       height - 6,
                       length=16,
                       function=close_window,
                       target=10)

    img = libtcod.image_load('diner_logo_sm.png')
    # libtcod.image_set_key_color(img, Color(0, 0, 0))

    # show the background image, at twice the regular console resolution
    #libtcod.image_blit_2x(img, mm, 37, 2)

    #libtcod.console_blit(mm, 0, 0, width, height, 0, 0, 0, 1.0, 1.0)

    while True:
        Input.update()

        if qt_button.draw(0,0) == 'close':
            return

        if ct_button.draw(0,0) == 'continue':
            return

        ng_button.draw(0, 0)
        terminal.refresh()
예제 #41
0
def play():

    while True:
        # Engine.Input.clear()
        Engine.Input.update()
        key = Engine.Input.key
        terminal.clear()
        terminal.color('white')
        # terminal.print_(terminal.state(terminal.TK_MOUSE_X), terminal.state(terminal.TK_MOUSE_Y),"HellowWorld")
        #test_anim.draw(terminal.state(terminal.TK_MOUSE_X),terminal.state(terminal.TK_MOUSE_Y))

        if key == terminal.TK_MOUSE_LEFT:
            x, y = terminal.state(terminal.TK_MOUSE_X), terminal.state(terminal.TK_MOUSE_Y)
            # animations.append(create_anim(x,y, Utils.heat_map_chrs, Utils.explosion_colors, number=50))
            #animations.append(Engine.Animation_System.Flame(x, y, size=25, density=70))
            choice = random.randint(0,5)

            # Engine.Animation_System.(Engine.Animation_System.A_FLAME, **kwargs)

            #choice = 0
            print choice

            # TODO: Cleaup Call. ADD KWARG support, Accept POS(x, y) instead of x,y. make all default variables overrideable via Kwargs

            animation_params={
                'origin': (x, y),
                'target': (x, y)
            }

            if choice == 0:
                    animations.append(
                            Engine.Animation_System.Animation('Flame', animation_params))   # , angle=random.randint(270, 270)))
            if choice == 1:
                    animations.append(
                            Engine.Animation_System.Animation('Burst', animation_params))
            if choice == 4:
                    animations.append(
                            Engine.Animation_System.Animation('Line', animation_params))
            if choice == 2:
                    animations.append(
                            Engine.Animation_System.Animation('IceBreath', animation_params))
            if choice == 3:
                    animations.append(
                            Engine.Animation_System.Animation('TinyFire', animation_params))
            if choice == 5:
                    animations.append(
                            Engine.Animation_System.Animation('Xmas', animation_params))

            #print len(animations)

        Render.draw_char(0, 15,15, '@')
        terminal.color('han')
        Render.draw_char(0, 17, 15, 'T')

        for ani in animations:
            result = ani.play()
            if result == 'Done':
                print "Want?"
                animations.remove(ani)

        #print len(animations)

        terminal.refresh()
예제 #42
0
def render_all():
    current_level.draw()
    UI.draw_hud()
    Animation.render_animations(animation_queue)
    terminal.refresh()