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

You stacked {0} out of 10 corpses.

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

Stuck?
See FAQ.md for spoilers!
""".format(self.calculate_score()), blt.state(blt.TK_WIDTH),
            blt.state(blt.TK_HEIGHT), blt.TK_ALIGN_CENTER)
        blt.refresh()
        while True:
            kp = blt.read()
            if kp == blt.TK_R:
                self.restart = True
            if kp in [blt.TK_CLOSE, blt.TK_ESCAPE, blt.TK_R]:
                break
        self.stop = True
예제 #2
0
def option_menu_input():
    if terminal.has_input():
        key = terminal.read()
        index = terminal.state(terminal.TK_CHAR) - ord('a')
        if key == terminal.TK_ESCAPE or index == 2:
            return OptionMenuSelection.BACK_TO_MAIN_MENU
        elif key == terminal.TK_CLOSE:
            save_game(World)
            terminal.close()
            sys.exit()
        elif index == 0:
            # change language
            if Texts.get_current_language() == 'fr':
                Texts.set_language('en')
            else:
                Texts.set_language('fr')
            show_main_options_menu()
        elif index == 1:
            # graphical mode
            if Interface.mode == GraphicalModes.ASCII:
                terminal.clear()
                Interface.change_graphical_mode(GraphicalModes.TILES)
            elif Interface.mode == GraphicalModes.TILES:
                terminal.clear()
                Interface.change_graphical_mode(GraphicalModes.ASCII)
            show_main_options_menu()
    return MainMenuSelection.NO_RESPONSE
예제 #3
0
    def renderGame(self, map):
        term.bkcolor(term.color_from_argb(255, 25, 25, 25))
        term.clear()

        for panel in self.main.panel:
            self.main.panel[panel].render()
        term.refresh()
예제 #4
0
def mpGameLoop(client):
    _map = Map(70, 50)
    player = client.players[client.name]
    mapReady = False
    while True:
        client.Loop()
        if client.msgQ.qsize() > 0:
            msg = client.msgQ.get()
            if msg['action'] == 'gameMap':
                _map.mapFrom(msg['gameMap'])
                mapReady = True
                playerx, playery = _map.findPlayerLoc()
                player.x = playerx
                player.y = playery
                terminal.clear()
                _map.do_fov(player.x, player.y, constants.FOV_RADIUS)
        if mapReady:
            _map.render_map()
            terminal.layer(1)
            for k, v in client.players.items():
                v.draw()
            terminal.refresh()
            terminal.layer(1)
            for k, v in client.players.items():
                v.clear()
            ex = handle_keys(player, _map.game_map)
            if ex == 1:
                _map.do_fov(player.x, player.y, constants.FOV_RADIUS)
                client.Send({
                    'action': 'posUpdate',
                    'posUpdate': [player.x, player.y]
                })
            if ex == 2:
                terminal.bkcolor(black)
                break
예제 #5
0
 def main_menu(self):
     self.game_state = 'main_menu'
     if self.current_game is None:
         options = [(75, 23, "(S)tart New Game"),
                    (75, 25, "(L)oad a Saved Game"),
                    (75, 27, "E(x)it Game")]
     else:
         options = [(75, 23, "(S)tart New Game"),
                    (75, 25, "(L)oad a Saved Game"),
                    (75, 27, "(R)esume Current Game"),
                    (75, 29, "E(x)it Game")]
     terminal.clear()
     gui.display_menu(options)
     while True:
         key = terminal.read()
         if key in (terminal.TK_CLOSE, terminal.TK_ESCAPE):
             sys.exit()
         elif key == terminal.TK_S:
             new_game = self.start_new_game()
             self.game_state = 'playing'
             new_game.play(game_master=self)
         elif key == terminal.TK_L:
             try:
                 self.load_game()
             except:
                 print('Load error.')
                 continue
             self.current_game.play(self)
         elif key == terminal.TK_X:
             sys.exit()
         elif key == terminal.TK_R and self.current_game is not None:
             self.game_state = 'playing'
             self.current_game.play(self)
예제 #6
0
def test_multiple_fonts():
    blt.set("window.title='Omni: multiple fonts in scene'")

    # Load several fonts
    blt.set("window.size=64x20; font: ../Media/VeraMono.ttf, size=10x20")
    blt.set("italic font: ../Media/VeraMoIt.ttf, size=10x20")
    blt.set("bold font: ../Media/VeraMoBd.ttf, size=10x20")
    blt.set("huge font: ../Media/VeraMono.ttf, size=20x40, spacing=2x2")

    blt.clear()
    blt.color("white")
    _, h = blt.puts(
        2,
        1, "If you [color=orange][font=italic]really[/font][/color] want, "
        "you can even put [color=orange][font=bold]emphasis[/font][/color] on a text. "
        "This works by loading several truetype tilesets with custom codepages to an "
        "unused code points and using [color=orange]font[/color] postformatting tag.",
        width=60)

    blt.puts(2,
             1 + h + 1,
             "[font=huge]It's pretty easy to print in bigger fonts as well.",
             width=60)
    blt.refresh()

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

    # Clean up
    blt.set(
        "window.size=80x25; font: default; italic font: none; bold font: none; huge font: none"
    )
예제 #7
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()
예제 #8
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)
예제 #9
0
def test_window_resize():
    blt.set(
        "window: title='Omni: window resizing', resizeable=true, minimum-size=27x5"
    )

    symbol = 0x2588

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

        key = blt.read()

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

    blt.set("window: resizeable=false")
예제 #10
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()
예제 #11
0
    def draw(self):
        terminal.clear()

        self.tree.draw()
        for ui_element in self.ui_elements:
            ui_element.draw()
        terminal.refresh()
예제 #12
0
파일: Map.py 프로젝트: Vapekreng/SR_old
def run_game():
    terminal.clear()
    TestMap = Maps()
    Hero = Mobs(19, 10, 0, '455', '@', 'human')
    # TODO: Перекинуть добавку моба в класс мобов
    TestMap.add_mob(Hero)
    aos = AreaOfSight.AoS(Hero, TestMap)
    TestMap.draw(aos.get())
    time = 0
    terminal.printf(0, 0, 'time=' + str(time))
    terminal.refresh()
    # TODO: Обработчик нажатий клавиш, мэйн луп, настройка клавиатуры через меню
    while True:
        key = terminal.read()
        while key not in Config.comand.values():
            key=terminal.read()
        if key == Config.comand['close'] or key == Config.comand['esc']:
            break
        time+=TestMap.move_mob(Hero, key)
        aos = AreaOfSight.AoS(Hero, TestMap)
        TestMap.draw(aos.get())
        terminal.printf(0, 0, 'time=' + str(time))
        terminal.refresh()
    terminal.clear()
    terminal.refresh()
예제 #13
0
파일: options.py 프로젝트: nuzcraft/RLTut
def options():
    choice = menu('OPTIONS', [
        'Old School Tiles   | ' + str(var.old_school_tiles),
        'Graphical Tiles    | ' + str(var.graphical_tiles),
        'BSP Map Generation | ' + str(var.bsp_map_gen),
        'BSP Full Rooms     | ' + str(var.FULL_ROOMS), 'Return to Main Menu'
    ], 24)
    if choice == 0:
        var.old_school_tiles = not var.old_school_tiles
        terminal.clear()
        options()
    elif choice == 1:
        var.graphical_tiles = not var.graphical_tiles
        terminal.clear()
        options()
    elif choice == 2:
        var.bsp_map_gen = not var.bsp_map_gen
        terminal.clear()
        options()
    elif choice == 3:
        var.FULL_ROOMS = not var.FULL_ROOMS
        terminal.clear()
        options()
    elif choice == 4:
        terminal.clear()
예제 #14
0
 def draw(self):
     terminal.clear()
     self.world.draw()
     self.player.draw()
     self.gui.draw()
     self.info.draw()
     terminal.refresh()
예제 #15
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()
예제 #16
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()
예제 #17
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()
예제 #18
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
예제 #19
0
 def main_menu(self, num, x, y, click, enter):
     self.input_state = 'main'
     dict = [
         ['[color=grey] New Game', 'New Game'],
         ['[color=grey]   Continue', '  Continue'],
         ['[color=grey]     Quit Game', '    Quit Game'],
     ]
     terminal.clear()
     terminal.layer(0)
     button0_rect = [self.center_text(dict[0][1]), 16, 8, 1]
     button1_rect = [self.center_text(dict[1][1]), 18, 10, 1]
     button2_rect = [self.center_text(dict[2][1]), 20, 13, 1]
     self.menu_num += num
     if self.menu_num > 2:
         self.menu_num = 0
     if self.menu_num < 0:
         self.menu_num = 2
     if x != 0 or y != 0:
         clickable = False
         if y >= button0_rect[1] and y <= button0_rect[1] + button0_rect[3]:
             if x >= button0_rect[
                     0] and x <= button0_rect[0] + button0_rect[2]:
                 clickable = True
                 self.menu_num = 0
         if y >= button1_rect[1] and y <= button1_rect[1] + button1_rect[3]:
             if x >= button1_rect[
                     0] and x <= button1_rect[0] + button1_rect[2]:
                 clickable = True
                 self.menu_num = 1
         if y >= button2_rect[1] and y <= button2_rect[1] + button2_rect[3]:
             if x >= button2_rect[
                     0] and x <= button2_rect[0] + button2_rect[2]:
                 clickable = True
                 self.menu_num = 2
     if self.menu_num == 0:
         terminal.printf(button0_rect[0], button0_rect[1], dict[0][1])
     else:
         terminal.printf(button0_rect[0], button0_rect[1], dict[0][0])
     if self.menu_num == 1 and num != 0:
         terminal.printf(button1_rect[0], button1_rect[1], dict[1][1])
         if self.coords == []:
             self.main_menu(num, 0, 0, False, False)
             return
     else:
         terminal.printf(button1_rect[0], button1_rect[1], dict[1][0])
     if self.menu_num == 2:
         terminal.printf(button2_rect[0], button2_rect[1], dict[2][1])
     else:
         terminal.printf(button2_rect[0], button2_rect[1], dict[2][0])
     terminal.printf(self.center_text('This is [color=red]Space  '), 11,
                     'This is [color=red]Space  ')
     #terminal.printf(self.center_text('press Enter'), 12, 'press Enter')
     terminal.refresh()
     if (click == True and clickable == True) or enter == True:
         if self.menu_num == 0:
             self.load_sector()
         if self.menu_num == 1:
             self.input_state = 'sector'
         if self.menu_num == 2:
             terminal.close()
예제 #20
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")
예제 #21
0
 def main_game_loop(self):
     blt.clear()
     self.render_map()
     self.render_entities()
     self.ecs.update()
     self.render_panel()
     blt.refresh()
예제 #22
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
예제 #23
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()
예제 #24
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()
예제 #25
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()
예제 #26
0
def show_lose_screen():
    # Clears the screen
    terminal.clear()

    # Prints lose message
    terminal.printf(6, 6, "[color=black][bkcolor=white] You  Lose! ")
    terminal.printf(5, 7, "[color=black][bkcolor=white] Press  enter ")
    terminal.printf(3, 8, "[color=black][bkcolor=white] to exit game.... ")
예제 #27
0
def main_loop():
    terminal.clear()
    menu = MenuControls()
    menu.print_caption()
    while not menu.time_to_quit:
        menu.print()
        menu.key_processing()
    terminal.clear()
예제 #28
0
    def update(self):
        terminal.clear()

        for e in self.entities:
            if e.is_visible:
                e.render()

        terminal.refresh()
예제 #29
0
def show_win_screen():
    # Clears the screen
    terminal.clear()

    # Prints win message
    terminal.printf(7, 6, "[color=black][bkcolor=white] You Win! ")
    terminal.printf(5, 7, "[color=black][bkcolor=white] Press  enter ")
    terminal.printf(3, 8, "[color=black][bkcolor=white] to exit game.... ")
예제 #30
0
def initialize_fov():
    terminal.clear()
    # set fov_map
    for y in range(var.MAP_HEIGHT):
        for x in range(var.MAP_WIDTH):
            lib.map_set_properties(var.fov_map, x, y,
                                   not var.map[x][y].block_sight,
                                   not var.map[x][y].blocked)
예제 #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
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()
예제 #33
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)
예제 #34
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()