コード例 #1
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
コード例 #2
0
    def __init__(self) -> None:
        self.game = Game()
        messages.on_log += self.on_log

        blt.open()

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

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

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

        htb_origin = quarter_window
        htb_display = DisplayElement.DisplayList(htb_origin)
        self.root.elements[self.game.htb] = DisplayElement.Clickable(
            htb_display, Rectangle(htb_origin, quarter_window))
        self.on_tableau_altered(self.game.htb)
コード例 #3
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
コード例 #4
0
def handle_mouse():
    (x, y) = (terminal.state(terminal.TK_MOUSE_X), terminal.state(terminal.TK_MOUSE_Y))
    if terminal.state(terminal.TK_MOUSE_LEFT):
        return {'left_click': {x, y}}
    elif terminal.state(terminal.TK_MOUSE_RIGHT):
        return {'right_click': {x, y}}
    return {}
コード例 #5
0
def handle_key(key, player, world):
    """Handle this player's next input key.  Return whether or not the input represents an action that ends the turn."""

    if key == blt.TK_CLOSE:
        exit()

    if key == blt.TK_RESIZED:
        w = blt.state(blt.TK_WIDTH)
        h = blt.state(blt.TK_HEIGHT)
        player.camera.resize(w, h)
        return False

    # NESW Movement
    if key == blt.TK_KP_8:
        return player.move(0, -1, world)
    elif key == blt.TK_KP_6:
        return player.move(1, 0, world)
    elif key == blt.TK_KP_2:
        return player.move(0, 1, world)
    elif key == blt.TK_KP_4:
        return player.move(-1, 0, world)

    # Diagonal Movement
    elif key == blt.TK_KP_7:
        return player.move(-1, -1, world)
    elif key == blt.TK_KP_9:
        return player.move(1, -1, world)
    elif key == blt.TK_KP_3:
        return player.move(1, 1, world)
    elif key == blt.TK_KP_1:
        return player.move(-1, 1, world)
コード例 #6
0
ファイル: window_resize.py プロジェクト: phomm/blt_samples
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")
コード例 #7
0
ファイル: menu.py プロジェクト: AapoPitkanen/BLT-RL
    def __init__(self,
                 header,
                 width,
                 options=None,
                 pos='c',
                 background_color="white"):
        self.header = header
        self.width = width
        self.options = options if options else [
        ]  # Avoid default argument mutation

        self.header_wrapped = wrap_tagged(self.header, self.width)
        self.header_height = len(self.header_wrapped)
        self.height = self.header_height + len(self.options)

        if pos == 'l':  # Position menu to the left
            self.topleft_x = 0
        elif pos == 'r':  # Position menu to the right
            self.topleft_x = terminal.state(terminal.TK_WIDTH) - self.width
        else:  # Position menu to the center
            self.topleft_x = int(
                (terminal.state(terminal.TK_WIDTH) - self.width) / 2)

        self.topleft_y = int(
            (terminal.state(terminal.TK_HEIGHT) - self.height) / 2)
        self.background_color = background_color
コード例 #8
0
 def __init__(self, x, y, world_width, world_height):
     self.world_width = world_width
     self.world_height = world_height
     self.width = blt.state(blt.TK_WIDTH)
     self.height = blt.state(blt.TK_HEIGHT)
     self.x = x
     self.y = y
     self.pan(0, 0)
コード例 #9
0
def get_constants():

    screen_width = blt.state(blt.TK_WIDTH)
    screen_height = blt.state(blt.TK_HEIGHT)
    map_width = int(blt.get("ini.Game.map_width"))
    map_height = int(blt.get("ini.Game.map_height"))

    depth = int(blt.get("ini.Game.depth"))
    min_size = int(blt.get("ini.Game.min_size"))
    full_rooms = {'False': False,
                  'True': True}[blt.get("ini.Game.full_rooms")]

    fov_algorithm = int(blt.get("ini.Game.fov_algorithm"))
    fov_light_walls = {'False': False,
                       'True': True}[blt.get("ini.Game.fov_light_walls")]
    fov_radius = int(blt.get("ini.Game.fov_radius"))

    max_monsters_per_room = int(blt.get("ini.Game.max_monsters_per_room"))
    max_items_per_room = 2

    camera_width = int(blt.get("ini.Game.camera_width"))
    camera_height = int(blt.get("ini.Game.camera_height"))

    panel_height = screen_height - camera_height - 3
    panel_y = camera_height + 2

    sidebar_width = screen_width - camera_width - 2
    sidebar_x = camera_width + 2

    message_x = 2
    message_width = camera_width
    message_height = panel_height - 2

    constants = {
        'screen_width': screen_width,
        'screen_height': screen_height,
        'map_width': map_width,
        'map_height': map_height,
        'depth': depth,
        'min_size': min_size,
        'full_rooms': full_rooms,
        'fov_algorithm': fov_algorithm,
        'fov_light_walls': fov_light_walls,
        'fov_radius': fov_radius,
        'max_monsters_per_room': max_monsters_per_room,
        'max_items_per_room': max_items_per_room,
        'camera_width': camera_width,
        'camera_height': camera_height,
        'panel_height': panel_height,
        'panel_y': panel_y,
        'sidebar_width': sidebar_width,
        'sidebar_x': sidebar_x,
        'message_x': message_x,
        'message_width': message_width,
        'message_height': message_height
    }

    return constants
コード例 #10
0
ファイル: auto_generated.py プロジェクト: phomm/blt_samples
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")
コード例 #11
0
ファイル: render_camera.py プロジェクト: Kavekha/NoGoNoMa
def get_map_coord_with_mouse_when_zooming():
    min_x, max_x, min_y, max_y = get_screen_bounds()
    mouse_pos_x = terminal.state(terminal.TK_MOUSE_X)
    mouse_pos_y = terminal.state(terminal.TK_MOUSE_Y)

    x = get_map_coord_with_zoom(mouse_pos_x) + min_x
    y = get_map_coord_with_zoom(mouse_pos_y) + min_y

    return x, y
コード例 #12
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
コード例 #13
0
def handle_mouse(key: int) -> Dict[str, Point]:
    mouse_position: Point = Point(x=blt.state(blt.TK_MOUSE_X) // 2,
                                  y=blt.state(blt.TK_MOUSE_Y) // 2)

    if key == blt.TK_MOUSE_LEFT:
        return {"left_click": mouse_position}
    elif key == blt.TK_MOUSE_RIGHT:
        return {"right_click": mouse_position}

    return {}
コード例 #14
0
def handle_mouse(mouse_input):
    mouse_x: int = terminal.state(terminal.TK_MOUSE_X)
    mouse_y: int = terminal.state(terminal.TK_MOUSE_Y)

    if mouse_input == terminal.TK_MOUSE_LEFT:
        return {'left_click': (mouse_x, mouse_y)}
    elif mouse_input == terminal.TK_MOUSE_RIGHT:
        return {'right_click': (mouse_x, mouse_y)}

    return {}
コード例 #15
0
def clear_map_layer():
    # Clear the map layer.
    prev_layer = terminal.state(terminal.TK_LAYER)
    terminal.layer(RenderLayer.MAP.value)

    terminal.bkcolor('black')
    terminal.clear_area(0, 0, terminal.state(terminal.TK_WIDTH),
                        terminal.state(terminal.TK_HEIGHT))

    terminal.layer(prev_layer)
コード例 #16
0
ファイル: render_engine.py プロジェクト: Kavekha/LostForest
    def _clear_all(self, entities):
        blt.layer(RenderLayer.ENTITIES.value)
        for entity in entities:
            self._clear_entity(entity)

        blt.layer(RenderLayer.INTERFACE.value)
        blt.clear_area(0, 0, blt.state(blt.TK_WIDTH, blt.TK_HEIGHT))

        blt.layer(RenderLayer.MENU.value)
        blt.clear_area(0, 0, blt.state(blt.TK_WIDTH, blt.TK_HEIGHT))
コード例 #17
0
ファイル: engine.py プロジェクト: Coul33t/iso_tbs
    def check_under_mouse(self):
        self.under_mouse = None

        mx = blt.state(blt.TK_MOUSE_X)
        my = blt.state(blt.TK_MOUSE_Y)
        off_mouse = Point(floor((mx / TERRAIN_SCALE_X) - self.map_offset.x),
                                     floor((my / TERRAIN_SCALE_Y) - self.map_offset.y))

        for a in self.actors:
            if a != self.unit_turn and a.x == off_mouse.x and a.y == off_mouse.y:
                self.under_mouse = a
コード例 #18
0
def get_names_under_mouse(entities, fov_map):
    (x, y) = (terminal.state(terminal.TK_MOUSE_X),
              terminal.state(terminal.TK_MOUSE_Y))
    # create a list with the names of all objects at the mouse's coordinates and in FOV
    names = [
        entity.name for entity in entities
        if entity.x == x and entity.y == y and libtcod.map_is_in_fov(
            fov_map, entity.x, entity.y) and entity.name != 'TargetingCursor'
    ]
    names = ', '.join(names)
    return names.capitalize(), x, y
コード例 #19
0
def button_text(w, h, text, color, offset='', bg=''):
    mouse_over = False
    width = terminal.measure(text)[0]
    mouse = (terminal.state(terminal.TK_MOUSE_X),
             terminal.state(terminal.TK_MOUSE_Y))
    if h == mouse[1] and (mouse[0] <= w + width and mouse[0] >= w):
        text = '[color=' + color + ']' + text
        mouse_over = True
    else:
        text = bg + text
    terminal.printf(w, h, text)
    return mouse_over
コード例 #20
0
def get_names_under_mouse(entities, fov_map):
    mouse_x: int = terminal.state(terminal.TK_MOUSE_X)
    mouse_y: int = terminal.state(terminal.TK_MOUSE_Y)

    names = [
        entity.name for entity in entities
        if entity.x == mouse_x and entity.y == mouse_y and fov_map[mouse_x,
                                                                   mouse_y]
    ]
    names = ', '.join(names)

    return names.capitalize()
コード例 #21
0
def clear_menu_layer():
    # Clear the menu and menu icon layers.
    prev_layer = terminal.state(terminal.TK_LAYER)
    terminal.layer(RenderLayer.MENU.value)
    terminal.clear_area(0, 0, terminal.state(terminal.TK_WIDTH),
                        terminal.state(terminal.TK_HEIGHT))

    terminal.layer(RenderLayer.MENU_ICON.value)
    terminal.clear_area(0, 0, terminal.state(terminal.TK_WIDTH),
                        terminal.state(terminal.TK_HEIGHT))

    terminal.layer(prev_layer)
コード例 #22
0
def button_sliding(w, h, text, color, key=False):
    mouse_over = False
    width = terminal.measure(text)[0]
    mouse = (terminal.state(terminal.TK_MOUSE_X),
             terminal.state(terminal.TK_MOUSE_Y))
    if key or (h == mouse[1] or h == mouse[1] - 1) and (mouse[0] <= w + width
                                                        and mouse[0] >= w):
        text = text
        mouse_over = True
    else:
        text = '[color=' + color + '] ' + text
    terminal.printf(w, h, text)
    return mouse_over
コード例 #23
0
def clear_layer(layer=None):
    # Clear the current (default) layer or a specified layer.
    prev_layer = terminal.state(terminal.TK_LAYER)

    if hasattr(layer, 'value'):
        terminal.layer(layer.value)
    elif layer:
        terminal.layer(layer)

    terminal.clear_area(0, 0, terminal.state(terminal.TK_WIDTH),
                        terminal.state(terminal.TK_HEIGHT))

    terminal.layer(prev_layer)
コード例 #24
0
def get_names_under_mouse():
    """Returns name of objects under the mouse cursor"""
    global visible_tiles

    x = t.state(t.TK_MOUSE_X)
    y = t.state(t.TK_MOUSE_Y)

    names = [
        obj.name for obj in objects
        if obj.x == x and obj.y == y and (obj.x, obj.y) in visible_tiles
    ]

    names = ', '.join(names)
    return names.capitalize()
コード例 #25
0
ファイル: render_engine.py プロジェクト: Kavekha/LostForest
    def _render_standard_menu(self, open_menu):
        blt.layer(RenderLayer.MENU.value)

        title = open_menu.title
        header = open_menu.header
        info = open_menu.info
        options = open_menu.display_options
        try:
            position = self.get_menu_position(open_menu.position)
        except AttributeError:
            print('menu does not have position. Use default.')
            position = None

        if position:
            x, y = position
        else:
            x, y = self.menu_title_placement
        x = (blt.state(blt.TK_WIDTH) - len(title)) // 2
        blt.printf(x, y, title)

        if position:
            x, y = position
        else:
            x, y = self.menu_header_placement
        x = (blt.state(blt.TK_WIDTH) - get_biggest_line_len(header)) // 2
        blt.printf(x, y, header)
        print(f'header len is {header}')
        print(f'lines in header is {get_biggest_line_len(header)}')

        if position:
            x, y = position
        else:
            x, y = self.menu_info_placement
        x = (blt.state(blt.TK_WIDTH) - len(info)) // 2
        blt.printf(x - (len(info) // 2), y, info)

        if options:
            letter_index = ord("a")
            if position:
                x, y = position
            else:
                x, y = self.menu_options_placement
            bigger_len = get_biggest_line_len(options)

            x = (blt.state(blt.TK_WIDTH) - bigger_len) // 2
            for option in options:
                text = f'{chr(letter_index)} - {option}'
                blt.printf(x, y, text)
                y += 1
                letter_index += 1
コード例 #26
0
def handle_targeting_keys(key):
    if key == blt.TK_ESCAPE:
        return {'exit': True}

    if key == blt.TK_MOUSE_LEFT:
        x = blt.state(blt.TK_MOUSE_X)
        y = blt.state(blt.TK_MOUSE_Y)
        return {'left_click': (x, y)}
    elif key == blt.TK_MOUSE_RIGHT:
        x = blt.state(blt.TK_MOUSE_X)
        y = blt.state(blt.TK_MOUSE_Y)
        return {'right_click': (x, y)}

    return {}
コード例 #27
0
def slider_h(w, h, width, p, color):
    bg = '[color=' + color + ']'
    mouse_over = False
    mouse = (terminal.state(terminal.TK_MOUSE_X),
             terminal.state(terminal.TK_MOUSE_Y))
    new = int(width * p)
    for i in range(new):
        bg = bg + '▓'
    if (h == mouse[1] or h == mouse[1] - 1) and (mouse[0] <= w + width
                                                 and mouse[0] >= w):
        mouse_over = True
        p = (mouse[0] - w) / width
    terminal.printf(w, h, bg)
    return mouse_over, p
コード例 #28
0
def handle_mouse(key, camera):
    #Handle mouse input and return screen coordinate, accounting for cellsize 8x16.

    (mouse_x, mouse_y) = ((int(terminal.state(terminal.TK_MOUSE_X) / 4)),
                          (int(terminal.state(terminal.TK_MOUSE_Y) / 2)))

    (mouse_x, mouse_y) = (camera.camera_x + mouse_x, camera.camera_y + mouse_y)

    if key == terminal.TK_MOUSE_LEFT:
        return {"left_click": (mouse_x, mouse_y)}
    elif key == terminal.TK_MOUSE_RIGHT:
        return {"right_click": (mouse_x, mouse_y)}

    return {}
コード例 #29
0
def get_names_under_mouse(entities, player, camera):
    mouse_x, mouse_y = camera.to_map_coordinates(blt.state(blt.TK_MOUSE_X),
                                                 blt.state(blt.TK_MOUSE_Y))

    # print(mouse_x, mouse_y)
    # print(entities.get((mouse_x, mouse_y)))
    names = [
        entity.name for entity in entities.values()
        if entities.get((mouse_x, mouse_y)) == entity and (
            mouse_x, mouse_y) in player.fov.fov_cells
    ]

    names = ', '.join(names)

    return names.capitalize()
コード例 #30
0
def draw_window(w, h, width, height, color, x, offset='[offset=-10x-10]'):
    draw_panel(w, h, width, height, color)
    draw_rect(w, h, width, height)
    close = 'X'
    mouse_over = False
    mouse = (terminal.state(terminal.TK_MOUSE_X),
             terminal.state(terminal.TK_MOUSE_Y))
    if (w + width == mouse[0] + 2 or w + width
            == mouse[0] + 1) and (h == mouse[1] or h == mouse[1] - 1):
        close = '[color=' + x + ']X'
        mouse_over = True
    terminal.printf(w + width - 2, h, '┬')
    terminal.printf(w + width - 2, h + 1, '└┤')
    terminal.printf(w + width - 1, h + 1, offset + close)
    return mouse_over
コード例 #31
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()
コード例 #32
0
ファイル: Input.py プロジェクト: joekane/DeepFriedSuperNova
 def cx(self):
     return terminal.state(terminal.TK_MOUSE_X)
コード例 #33
0
ファイル: Input.py プロジェクト: joekane/DeepFriedSuperNova
 def lbutton(self):
     return bool(terminal.state(terminal.TK_MOUSE_LEFT))
コード例 #34
0
ファイル: Input.py プロジェクト: joekane/DeepFriedSuperNova
 def rbutton(self):
     return bool(terminal.state(terminal.TK_MOUSE_RIGHT))
コード例 #35
0
ファイル: Input.py プロジェクト: joekane/DeepFriedSuperNova
def read_key_chr():
    return terminal.state(terminal.TK_CHAR)
コード例 #36
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()
コード例 #37
0
ファイル: Input.py プロジェクト: joekane/DeepFriedSuperNova
 def cy(self):
     return terminal.state(terminal.TK_MOUSE_Y)