Beispiel #1
0
def main_menu():
    img = tcod.ImageFile("menu_background1.png")
    con = tcod.root_console

    while not tcod.is_window_closed():
        img.blit_2x(con)
        con.set_default_foreground(tcod.COLOR_LIGHT_YELLOW)
        con.print_ex(const.SCREEN_WIDTH/2, const.SCREEN_HEIGHT/2 - 4, align=tcod.ALIGN_CENTER,
                     text="Random Life")
        con.print_ex(const.SCREEN_WIDTH/2, const.SCREEN_HEIGHT-2, align=tcod.ALIGN_CENTER,
                     text="A tutorial roguelike using libtcod")

        key = utils.menu('', ['Start a new game', 'Resume last game', 'Quit'], width=24)

        if key.c == ord('a'): # New game
            game_loop(new_game())
        elif key.c == ord('b'): # Load game
            try:
                player = load_game()
                game_loop(player)
            except:
                utils.msgbox('Loading the game failed: are you sure one exists?')
                continue
        elif key.c == ord('c') or key.c == ord('q'): # Quit
            break;
Beispiel #2
0
def level_up_screen(player):
    choice = None
    while choice is None:
        choice = utils.menu('Level up! Choose a stat to raise:\n',
                      ['Constitution (+20 HP, from ' + str(player.fighter.max_hp) + ')',
                       'Strength (+1 attack, from ' + str(player.fighter.power) + ')',
                       'Agility (+1 defense, from ' + str(player.fighter.defense) + ')'], 40)

        if choice.c == ord('a'): # more hp
            player.fighter.max_hp += 20
            player.fighter.hp += 20
        elif choice.c == ord('b'): # more power!
            player.fighter.power += 1
        elif choice.c == ord('c'):
            player.fighter.defense += 1
        else:
            choice = None # Try again