Beispiel #1
0
    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;

tcod.set_custom_font('fonts/consolas12x12_gs_tc.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
tcod.init_root(const.SCREEN_WIDTH, const.SCREEN_HEIGHT, 'Random Life', False)
console = tcod.Console(const.MAP_WIDTH, const.MAP_HEIGHT)

libtcod.sys_set_fps(const.LIMIT_FPS)

if __name__ == '__main__':
    main_menu()
Beispiel #2
0
#!/usr/bin/env python
import tcod
import game

width = game.config.parser.getint("core", "width")
height = game.config.parser.getint("core", "height")
fullscreen = game.config.parser.getboolean("core", "fullscreen")

tcod.set_custom_font('fonts/consolas12x12_gs_tc.png', tcod.font.TYPE_GREYSCALE | tcod.font.LAYOUT_TCOD)
tcod.init_root(width, height, title='NP-Complete', fullscreen=fullscreen)
tcod.set_fps_limit(25)

if __name__ == '__main__':
    game.main_menu()