Exemple #1
0
def start_menu():
    title.init_blood()
    libtcod.console_credits_reset()

    finished_libtcod_credits = False

    selection = 0
    while True:
        title.update()

        libtcod.console_clear(0)

        title.draw_blood()
        title.draw_title()

        libtcod.console_set_background_color(0, libtcod.dark_grey)
        libtcod.console_rect(0, 24, 14, 32, 7, False, libtcod.BKGND_MULTIPLY)

        libtcod.console_set_foreground_color(0, libtcod.red)
        libtcod.console_print_center(0, 40, 15, libtcod.BKGND_NONE, "Brutal RL: Slaves to Slaughter")

        libtcod.console_set_foreground_color(0, libtcod.white)
        libtcod.console_print_left(0, 35, 17, libtcod.BKGND_NONE, "New Game")
        libtcod.console_print_left(0, 35, 18, libtcod.BKGND_NONE, "Load Game")
        libtcod.console_print_left(0, 35, 19, libtcod.BKGND_NONE, "Quit")

        libtcod.console_print_left(0, 33, 17 + selection, libtcod.BKGND_NONE, ">")
        libtcod.console_print_left(0, 45, 17 + selection, libtcod.BKGND_NONE, "<")

        if not finished_libtcod_credits:
            finished_libtcod_credits = libtcod.console_credits_render(65, 43, True)

        libtcod.console_flush()

        key = libtcod.console_check_for_keypress(libtcod.KEY_PRESSED)

        if key.vk == libtcod.KEY_ESCAPE:
            if selection == 2:
                raise SetState("quit")

            else:
                selection = 2

        elif key.vk in DIRECTION_KEYS and DIRECTION_KEYS[key.vk][0] == 0:
            selection += DIRECTION_KEYS[key.vk][1]
            selection %= 3

        elif key.vk in [libtcod.KEY_ENTER, libtcod.KEY_KPENTER]:
            raise SetState([new_game, load_game, "quit"][selection])

        mouse = libtcod.mouse_get_status()
        if mouse.lbutton:
            title.set_full(mouse.cx, mouse.cy)

        elif mouse.rbutton:
            title.set_empty(mouse.cx, mouse.cy)
Exemple #2
0
def test_credits(console):
    libtcodpy.console_credits_render(0, 0, True)
    libtcodpy.console_credits_reset()