コード例 #1
0
def print_rect(dest, x, y, w, h, text):
    # LIBTCOD
    # libtcod.console_print_rect(dest, x, y, w, h, text)

    # BEARLIB
    terminal.layer(dest)
    terminal.print_(x, y, "{0}[bbox={1}x{2}]".format(text, w, h))
コード例 #2
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
コード例 #3
0
ファイル: Render.py プロジェクト: joekane/DeepFriedSuperNova
def print_rect(dest, x, y, w, h, text):
    # LIBTCOD
    # libtcod.console_print_rect(dest, x, y, w, h, text)

    # BEARLIB
    terminal.layer(dest)
    terminal.print_(x, y, "{0}[bbox={1}x{2}]".format(text, w, h))
コード例 #4
0
ファイル: draw.py プロジェクト: adael/goldminer
def draw_actor_stats(actor):
    r = settings.gui_rect
    terminal.color('azure')

    draw_rect(r)

    x = r.left + 2
    y = r.top + 2
    width = r.width - 4

    draw_gui_stat(actor.fighter.hp, x, y, width, settings.hp_colors)

    y += 3
    draw_gui_stat(actor.fighter.water, x, y, width, settings.water_colors)

    y += 3
    draw_gui_stat(actor.fighter.food, x, y, width, settings.food_colors)

    y += 3
    draw_gui_stat(actor.fighter.fatigue, x, y, width,
                  colors.get_bright_range(colors.brown))

    y += 3
    terminal.print_(x, y, "Position: {}x{}".format(actor.x, actor.y))

    y += 4
    terminal.color("#AA6939")
    terminal.print_(x, y, "Inventory:")
    draw_double_line(x, y + 1, width)
    draw_mini_inventory(actor.inventory, x, y + 3, width)
コード例 #5
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()
コード例 #6
0
def draw_star(star, fov_map):
    visible = libtcod.map_is_in_fov(fov_map, star[0], star[1])
    if visible:
        terminal.bkcolor('darkest grey')
    terminal.color(star[2])
    terminal.print_(star[0], star[1], '.')
    terminal.color('black')
    terminal.bkcolor('black')
コード例 #7
0
ファイル: draw.py プロジェクト: adael/goldminer
def draw_menu_state(lst):
    terminal.clear()
    caption = ".*{Gold Miner}*."
    terminal.color("yellow")
    terminal.print_(10, 10, caption)
    draw_double_line(10, 11, len(caption))
    draw_select_box(lst, 10, 13)
    terminal.refresh()
コード例 #8
0
def print_line(dest, x, y, text): # bottom-right for BEARLIB
    # LIBTCOD
    # libtcod.console_print_ex(dest, x, y, flag, alignment, text)

    # BERALIB

    terminal.layer(dest)
    terminal.print_(x, y, text)
コード例 #9
0
def initialize_with_bkcolor(old_color, new_color, width, height, startx,
                            starty):
    terminal.bkcolor(new_color)
    terminal.color('white')
    for i in range(width):
        for j in range(height):
            terminal.print_(startx + i, starty + j, ' ')
    terminal.bkcolor(old_color)
コード例 #10
0
def print_line(dest, x, y, text):  # bottom-right for BEARLIB
    # LIBTCOD
    # libtcod.console_print_ex(dest, x, y, flag, alignment, text)

    # BERALIB

    terminal.layer(dest)
    terminal.print_(x, y, text)
コード例 #11
0
    def intro(self):
        blt.clear()
        blt.print_(
            0, 0, """Move: WASD/Arrow keys
Attack: WASD/Arrow keys
Rest: Space
Aim: Stack 10 corpses!""")
        blt.refresh()
        blt.read()
コード例 #12
0
    def draw_window(self):

        x = self.x
        y = self.y
        w = self.w
        h = self.h
        header_len = 0

        #Draw border
        for dx in range(x, x+w):
            for dy in range(y, y+h):
                terminal.layer(1)
                terminal.color('darker gray')
                terminal.put(dx, dy, 0x2593)
                if dx == x and dy == y:
                    terminal.puts(dx, dy,'[color='+self.color+']'+'╔')
                elif dx == x+w-1 and dy == y+h-1:
                    terminal.puts(dx, dy,'[color='+self.color+']'+'╝')
                elif dx == x and dy == y+h-1:
                    terminal.puts(dx, dy,'[color='+self.color+']'+'╚')
                elif dx == x+w-1 and dy == y:
                    terminal.puts(dx, dy,'[color='+self.color+']'+'╗')
                elif dx == x or dx == x+w-1:
                    terminal.puts(dx, dy,'[color='+self.color+']'+'║')
                elif dy == y or dy == (y+h-1):
                    terminal.puts(dx, dy,'[color='+self.color+']'+'═')

        if self.header is not None:
            header_len = len(self.header)
            for h in self.header:
                terminal.layer(2)
                terminal.printf(x+1, y+1+(self.header.index(h)), '[color=white][font=big]'+h)
            terminal.print_(x+1, y+1+header_len, '\n')
        if self.options is not None:
            

            letter_index = ord('a')

            for option in self.options:
                opt_index = self.options.index(option)
                wrapped_option = textwrap.wrap(option, self.w-4)
                if opt_index < 26:
                    letter_index = ord('a') + opt_index
                else:
                    letter_index = ord('0') + opt_index - 26
                terminal.layer(2)
                if len(wrapped_option) == 1:
                    text = '[font=big](' + chr(letter_index) + ') ' + option
                    terminal.printf(x+1, y+1+header_len+1+(self.options.index(option)), '[color=white]'+ text)
                else:
                    for o in wrapped_option:
                        if wrapped_option.index(o) == 0:
                            text = '[font=big](' + chr(letter_index) + ') ' + o
                            terminal.printf(x+1, y+1+header_len+1+(self.options.index(option)), '[color=white]'+ text)
                        else:
                            text = '[font=big]    ' + o
                            terminal.printf(x+1, y+1+header_len+1+(self.options.index(option)+wrapped_option.index(o)), '[color=white]'+ text)
コード例 #13
0
ファイル: draw.py プロジェクト: adael/goldminer
def draw_window(rect_, caption, color="white", bkcolor="black"):
    push_colors()
    terminal.color(color)
    terminal.bkcolor(bkcolor)
    terminal.clear_area(rect_.x, rect_.y, rect_.width, rect_.height)
    draw_line(rect_.x + 1, rect_.y + 2, rect_.width - 2, "[U+2594]")
    draw_rect(rect_)
    terminal.print_(rect_.center_x, rect_.y + 1, "[align=center]" + caption)
    pop_colors()
コード例 #14
0
 def draw(self, xy: vec, layer: int = 0) -> None:
     blt.color(self.fg_colour.blt_colour())
     if self.bg_colour is not None:
         blt.bkcolor(self.bg_colour.blt_colour())
     xy = xy + self.xy
     if self.bbox is None:
         blt.print_(xy.x, xy.y, self.text)
     else:
         blt.print_(xy.x, xy.y, self.text, self.bbox.x, self.bbox.y,
                    self.align_h.value + self.align_v.value)
コード例 #15
0
def animate_explosion(game_state, explosion_shape):
    if explosion_shape and game_state == GameStates.EXPLOSION:
        shades = ['lighter', 'light', '', 'dark', 'darker']
        terminal.layer(2)
        for pts in explosion_shape.points:
            shade = shades[libtcod.random_get_int(0, 0, len(shades) - 1)]
            if shade:
                terminal.color(shade + ' violet')
            else:
                terminal.color('violet')
            terminal.print_(pts[0], pts[1], '*')
        terminal.layer(0)
コード例 #16
0
ファイル: draw.py プロジェクト: adael/goldminer
def draw_history(history: History):
    r = settings.status_rect
    x, y = r.x + 1, r.bottom - 2
    color = "white"
    for msgtime, msg in reversed(history.messages):
        if y <= r.y:
            return
        s = "{} [color={}][bbox={}]{}".format(msgtime.strftime("%H:%M:%S"),
                                              color, r.width, msg)
        terminal.print_(x, y, s)
        (_, mh) = terminal.measure(s)
        y -= mh
        color = "dark gray"
コード例 #17
0
def animate_line_draw(game_state, lineshot_pts, lineshot_clr):
    if lineshot_pts and game_state == GameStates.LINESHOT:
        terminal.layer(2)
        terminal.color(lineshot_clr)
        if abs(lineshot_pts[-1][1] -
               lineshot_pts[0][1]) > abs(lineshot_pts[-1][0] -
                                         lineshot_pts[0][0]):
            symbol = '|'
        else:
            symbol = '-'
        for pts in lineshot_pts:
            terminal.print_(pts[0], pts[1], symbol)
        terminal.layer(0)
コード例 #18
0
def draw_targeting_box(x, y):
    terminal.layer(2)
    terminal.color('lightest red')
    terminal.print_(x + 1, y - 1, '[color=dark red][U+2511]')
    terminal.print_(x - 1, y + 1, '[color=dark red][U+2515]')
    terminal.print_(x + 1, y + 1, '[color=dark red][U+2519]')
    terminal.print_(x - 1, y - 1, '[color=dark red][U+250D]')
    terminal.color('black')
    terminal.layer(0)
コード例 #19
0
ファイル: draw.py プロジェクト: adael/goldminer
def draw_mini_inventory(inventory: Inventory, x: int, y: int, width: int):
    """
    It draws the in-game mini-inventory
    """
    items = [
        "[color={}]{} [/color]".format(item.color, item.char)
        for item in inventory.items
    ]

    while len(items) < inventory.capacity:
        items.append("[color=#404040]- [/color]")

    lines = chunks(items, ceil(width / 2))

    for line_items in lines:
        terminal.print_(x, y, "[bbox={}]".format(width) + "".join(line_items))
        y += 1
コード例 #20
0
ファイル: draw.py プロジェクト: adael/goldminer
def draw_inventory_state_items(items, selected_index):
    line_x = settings.gui_rect.x + 1
    line_y = settings.gui_rect.y + 3
    line_w = settings.gui_rect.width - 3
    item_w = 2
    item_h = 3

    index = 0
    for item in items:
        text_x = line_x + 4
        text_y = line_y + 1

        if index == selected_index:
            item_bg = colors.inventory_item_hover_bg
            item_fg = colors.inventory_item_hover_fg
        else:
            item_bg = colors.inventory_bk_color
            item_fg = colors.inventory_item_fg

        label = "[bbox={}][color=white] {}[/color]".format(
            line_w, item.description)
        _, mh = terminal.measure(label)
        cy = mh

        # draw icon
        terminal.bkcolor(colors.inventory_bk_color)
        terminal.color(colors.white)
        draw_corners(line_x, line_y, line_x + item_w, line_y + item_w)
        terminal.color(item.color)
        terminal.put(line_x + 1, line_y + 1, item.char)

        # draw highlight
        terminal.bkcolor(item_bg)
        terminal.clear_area(text_x, line_y, line_w - 4, item_h)

        # draw text
        terminal.print_(text_x, text_y, label)

        # restore background color
        terminal.bkcolor(colors.black)

        # calculations
        line_y += max(3, cy + 1)
        index += 1
コード例 #21
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()
コード例 #22
0
def menu(header,
         options,
         width,
         screen_width,
         screen_height,
         position=None,
         type=None):
    if len(options) > 26:
        raise ValueError('Cannot have a menu with more than 26 options')

    # calculate total height for the header (after auto-wrap) and one line per option
    header_height = libtcod.console_get_height_rect(0, 0, 0, width,
                                                    screen_height, header)
    height = len(options) + header_height + 2

    # create an offscreen console that represents the menu's window
    terminal.layer(2)
    terminal.clear_area(0, 0, screen_width, screen_height)

    if type == 'main':
        x = int(screen_width / 2 - 9)
        y = int(screen_height / 2 + 5 + height)
    elif type == 'inventory':
        x = int(screen_width / 2 + 25)
        y = int(screen_height / 2)
    else:
        x = int(screen_width / 2)
        y = int(screen_height / 2)

    #while True:
    terminal.print_(x + 1, y, '[color=white]' + header)

    # print all the options
    h = header_height
    letter_index = ord('a')
    run = 0
    for option_text in options:
        text = option_text
        if position is not None:
            if run == position:
                terminal.print_(x + 1, h + y + 1, '[color=yellow]' + text)
            else:
                terminal.print_(x + 1, h + y + 1, '[color=white]' + text)
        else:
            terminal.print_(x + 1, h + y + 1, '[color=white]' + text)
        h += 1
        letter_index += 1
        run += 1

    # present the root console to the player and wait for keypress
    terminal.refresh()
コード例 #23
0
ファイル: terminal.py プロジェクト: Yuffster/beary
 def puts(self, text, x=0, y=0, color=None):
     if color is not None:
         if len(color) == 3:
             color = colors.rgb(*color)
         elif len(color) == 4:
             color = colors.argb(*color)
     if color is not None and color != self._color:
         term.color(color)
     n = term.print_(x, y, str(text))
     self._cursor = n
     if color != self._color:
         term.color(self._color)
     return n
コード例 #24
0
ファイル: draw.py プロジェクト: adael/goldminer
def draw_inventory_window(inventory: Inventory, selected_index):
    draw_window(settings.gui_rect, "Inventory window",
                colors.inventory_item_hover_bg, colors.inventory_bk_color)

    if inventory.is_empty():
        inner_width = settings.gui_rect.width - 2

        px = settings.gui_rect.x + 4
        py = settings.gui_rect.y + 4
        msg = texts.pick(texts.inventory_is_empty)

        terminal.print_(
            px, py, "[bbox={}][color={}]{}".format(inner_width, colors.teal,
                                                   msg))
        terminal.print_(
            px, py + 2,
            "[bbox={}][color={}]<< {}".format(inner_width, colors.white,
                                              texts.press_back))
    else:
        draw_inventory_state_items(inventory.items, selected_index)

    terminal.refresh()
コード例 #25
0
ファイル: bearlib.py プロジェクト: joekane/DeepFriedSuperNova
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()
コード例 #26
0
    def win(self):
        blt.clear()
        blt.set('window:size=60x20')
        blt.set('font: UbuntuMono-R.ttf, size=14')
        blt.print_(
            0, 0, """
Suddenly the air fills with applause.
An unseen crowd chants "TEN-STACK, TEN-STACK!"
as a pair of guards leads you out of the arena to freedom.
A bitter freedom, still trapped in a society
with daily trials by combat,
and trapped with the memory of your own trial.

*** Press Escape ***
*** Press R to restart ***
""", 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
コード例 #27
0
ファイル: draw.py プロジェクト: adael/goldminer
def draw_select_box(control, x, y):
    padding_left = 2
    w, h = calculate_select_box_dimension(control)
    w += padding_left

    index = 0
    py = 0
    for item in control.items:
        color = colors.white
        if item.active and control.item_focused_index == index:
            color = colors.yellow
        elif not item.active:
            color = colors.gray

        box = "[bbox={}]".format(w - padding_left)
        (_, height) = terminal.measure(box + item.label)
        terminal.color(color)
        terminal.print_(x + 2, y + py, box + item.label)
        if index == control.item_focused_index:
            terminal.color(color)
            terminal.put(x, y + py, ">")

        py += height
        index += 1
コード例 #28
0
def render_bar(x, y, total_width, name, value, maximum, bar_color, back_color):
    terminal.layer(0)

    bar_width = int(float(value) / maximum * total_width)

    # Render background first
    terminal.bkcolor(back_color)
    for i in range(total_width):
        terminal.print_(x + i, y, ' ')

    # Render bar on top
    terminal.bkcolor(bar_color)
    for i in range(bar_width):
        terminal.print_(x + i, y, ' ')

    terminal.layer(1)
    txt = name + ': ' + str(value) + '/' + str(maximum)
    terminal.print_(int(total_width / 2 - len(txt) / 2), int(y),
                    '[align=center][color=white]' + txt)

    # clean up
    terminal.bkcolor('black')
コード例 #29
0
ファイル: draw.py プロジェクト: adael/goldminer
def draw_progress(x, y, width, percent, color, bkcolor="dark gray"):
    fill_width = int(percent * width / 100)
    terminal.print_(x, y, "[bkcolor={}]".format(bkcolor) + (" " * width))
    terminal.print_(x, y, "[bkcolor={}]".format(color) + (" " * fill_width))
コード例 #30
0
ファイル: draw.py プロジェクト: adael/goldminer
def draw_progress_label(x, y, label, value, max_value, color):
    label += " [color={}]{}[color=white]/{}".format(color, value, max_value)
    terminal.print_(x, y, label)
コード例 #31
0
ファイル: draw.py プロジェクト: adael/goldminer
def draw_line(x, y, width, code="[U+2500]"):
    terminal.print_(x, y, code * width)
コード例 #32
0
ファイル: bearlib.py プロジェクト: joekane/DeepFriedSuperNova
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)
コード例 #33
0
ファイル: draw.py プロジェクト: adael/goldminer
def draw_generate_world():
    terminal.color(colors.black)
    terminal.bkcolor(colors.white_ice)
    terminal.clear()

    terminal.print_(10, 10, "Generating world...")
コード例 #34
0
def render_equip_panel(x,
                       y,
                       total_width,
                       total_height,
                       items,
                       active_turrets,
                       game_state,
                       equip_index=None):
    terminal.layer(0)
    initialize_with_bkcolor('black', 'darkest azure', total_width,
                            total_height, x, y)
    draw_panel_box('white', total_width, total_height, x, y)

    x = x + 1
    terminal.print_(int(x + total_width / 2 - len('LOADOUT PANEL (i)') / 2), y,
                    'LOADOUT PANEL (i)')
    terminal.print_(x, y + 2, 'MANUAL')
    terminal.print_(x, y + 5, 'AUTO')
    terminal.layer(1)
    terminal.print_(x, y + 2, '________________')
    terminal.print_(x, y + 5, '________________')
    terminal.layer(0)

    run = 0
    man_height = 3
    auto_height = 6
    for item_entity in items:
        if item_entity in active_turrets:
            bground = 'green'
            status = 'RDY'
        elif item_entity.item.charge_time == item_entity.item.max_charge_time:
            bground = 'red'
            status = 'FIRING'
        else:
            bground = 'yellow'
            status = 'LOAD' + str(item_entity.item.charge_time + 1)

        if item_entity.item.targeting == 'manual':
            action = 'Fire'
            bground = 'green'
            status = 'RDY'
            h = man_height
            man_height += 1
        elif item_entity.item.targeting == 'auto_on':
            action = 'Disable'
            h = auto_height
            auto_height += 1
        elif item_entity.item.targeting == 'auto_off':
            action = 'Enable'
            bground = 'yellow'
            status = 'DSABLD'
            h = auto_height
            auto_height += 1
        else:
            break

        item_name = ': ' + item_entity.name + '{' + str(
            item_entity.item.quantity) + ')'
        if equip_index is not None and run == equip_index:
            if game_state == GameStates.DROP_EQUIP:
                terminal.print_(x, y + h, '[color=black][bkcolor=yellow]DROP')
            else:
                terminal.print_(x, y + h,
                                '[color=black][bkcolor=yellow]' + action)
            terminal.print_(x + len(action), y + h,
                            '[color=white]' + item_name)
        else:
            terminal.print_(x, h + y, '[color=' + bground + ']' + status)
            terminal.print_(x + len(status), h + y,
                            '[color=white]' + item_name)

        h += 2
        run += 1
    terminal.bkcolor('black')