Пример #1
0
def main_menu():
    img = libtcod.image_load('moon.png')

    while not libtcod.console_is_window_closed():
        libtcod.image_blit_2x(img, 0, 0, 0)

        libtcod.console_set_foreground_color(0, libtcod.light_yellow)
        libtcod.console_print_center(0, SCREEN_WIDTH / 2,
                                     (SCREEN_WIDTH / 2) - 4,
                                     libtcod.BKGND_NONE, 'Moon Game')
        libtcod.console_print_center(0, SCREEN_WIDTH / 2, SCREEN_HEIGHT - 2,
                                     libtcod.BKGND_NONE, 'James Disley')

        choice = menu('', ['Play a new game', 'Continue last game', 'Quit'],
                      24)

        if choice == 0:
            new_game()
            play_game()
        if choice == 1:
            try:
                load_game()
            except:
                msgbox('\n No saved game to load.\n', 24)
                continue
            play_game()
        elif choice == 2:
            break
Пример #2
0
def main_menu():
    img = libtcod.image_load('menu_background.png')

    while not libtcod.console_is_window_closed():
        # show the background image, at twice the regular console resolution
        libtcod.image_blit_2x(img, 0, 0, 0)

        # show the game's title, and some credits!
        libtcod.console_set_foreground_color(0, libtcod.light_yellow)
        libtcod.console_print_center(0, SCREEN_WIDTH / 2,
                                     SCREEN_HEIGHT / 2 - 6, libtcod.BKGND_NONE,
                                     'TOMBS OF THE ANCIENT KINGS')
        libtcod.console_print_center(0, SCREEN_WIDTH / 2,
                                     SCREEN_HEIGHT / 2 - 4, libtcod.BKGND_NONE,
                                     'By Jotaf')

        # show options and wait for the player's choice
        choice = menu('', ['Play a new game', 'Continue last game', 'Quit'],
                      24)

        if choice == 0:  # new game
            new_game()
            play_game()
        elif choice == 1:  # load last game
            try:
                load_game()
            except:
                msgbox('\n No saved game to load.\n', 24)
                continue
            play_game()
        elif choice == 2:  # quit
            break
Пример #3
0
def main_menu():
	img = libtcod.image_load('menu_background1.png')
	
	while not  libtcod.console_is_window_closed():
		#show the background image, at twice the regular console resolution
		libtcod.image_blit_2x(img, 0, 0, 0)
		
		#show the game's title, and some credits!
		libtcod.console_set_foreground_color(0, libtcod.black)
		libtcod.console_print_center(0, SCREEN_WIDTH/2, SCREEN_HEIGHT/2-4, libtcod.BKGND_NONE, 'P U R G A T O R I O')
		libtcod.console_set_foreground_color(0, libtcod.white)
		libtcod.console_print_center(0, SCREEN_WIDTH/2, SCREEN_HEIGHT-2, libtcod.BKGND_NONE, 'By CitizenArcane')
		
		#show options and wait for the player's choice
		choice = menu(' ', ['Play a new game', 'Continue last game', 'Quit'], 24)
		
		if choice == 0: #new game
			new_game()
			play_game()
		elif choice == 1: #load last game
			try:
				load_game()
			except:
				msgbox('\n No saved game to load. \n', 24)
				continue
			play_game()
		elif choice == 2: #quit
			break
Пример #4
0
def main_menu():
    img = libtcod.image_load('menu_background1.png')

    while not libtcod.console_is_window_closed():
        #show the background image, at twice the regular console resolution
        libtcod.image_blit_2x(img, 0, 0, 0)

        #Show game details, credits, etc
        libtcod.console_set_foreground_color(0, libtcod.light_yellow)
        libtcod.console_print_center(0, SCREEN_WIDTH / 2,
                                     SCREEN_HEIGHT / 2 - 4, libtcod.BKGND_NONE,
                                     'The Frontier')
        libtcod.console_print_center(0, SCREEN_WIDTH / 2, SCREEN_HEIGHT - 2,
                                     libtcod.BKGND_NONE,
                                     'By Winkle and Littlefoot')

        #show options and wait for the player's choice
        choice = menu('', ['Play a new game', 'Continue last game', 'Quit'],
                      24)

        if choice == 0:  #New game
            new_game()
            play_game()

        if choice == 1:  #Load last save game
            try:
                load_game()
            except:
                msgbox('\n No save game to load\n', 24)
                continue
            play_game()

        elif choice == 2:  #Quit
            break
Пример #5
0
def main_menu():
    img = libtcod.image_load('menu_background.png')
 
    while not libtcod.console_is_window_closed():
        
        #show the background image, at twice the regular console resolution
        libtcod.image_blit_2x(img, 0, 0, 0)
 
        #show the game's title, and some credits!
        libtcod.console_set_foreground_color(0, libtcod.light_yellow)
        libtcod.console_print_center(0, SCREEN_WIDTH/2, SCREEN_HEIGHT/2-4, libtcod.BKGND_NONE, 'Rogue-LIKE!')
        libtcod.console_print_center(0, SCREEN_WIDTH/2, SCREEN_HEIGHT-2, libtcod.BKGND_NONE, 'By RobBbot')
 
        #show options and wait for the player's choice
        choice = menu('', ['Play a new game', 'Continue last game', 'Controls', 'Quit'], 24)
 
        if choice == 0:  #new game
            new_game()
            play_game()
        if choice == 1:  #load last game
            try:
                load_game()
            except:
                msgbox('\n No saved game to load.\n', 24)
                continue
            play_game()
        elif choice == 2: 
            msgbox('\n "g" will pickup items\n\n "i" will bring up your inventory \n\n "d" will drop an item on the ground\n\n Arrow keys move the @ around\n\n Casting Spells requires you to click on the\n mob you want to target after selecting \n the scroll from  your inventory')
        elif choice == 3:  #quit
            break
Пример #6
0
def mainMenu():
    image = libtcod.image_load("menu_background1.png")

    while not libtcod.console_is_window_closed():
        #Shows the background image
        libtcod.image_blit_2x(image, 0, 0, 0)

        #shows the game title and author
        libtcod.console_set_foreground_color(0, libtcod.light_orange)
        libtcod.console_print_center(0, SCREEN_WIDTH/2, SCREEN_HEIGHT/2-5, libtcod.BKGND_NONE, "Jules Quest")
        libtcod.console_print_center(0, SCREEN_WIDTH/2, SCREEN_HEIGHT/2-3, libtcod.BKGND_NONE, "By Julian Jocque")

        menuOptions = ["New Game", "Continue", "Quit"]
        #shows options and waits for a choice

        choice = menu("", menuOptions, MAIN_MENU_WIDTH)

        if choice == 0: #new game
            newGame()
            playGame()
        elif choice == 1: #continue
            try:
                loadGame()
                playGame()
            except:
                msgBox("\n No save file found.\n", MAIN_MENU_WIDTH)
                continue
        #elif choice == 2: #show instructions
        #    menu("\nArrow Keys to move and attack monsters.\nG to pickup an item you are standing on.\nI to open Inventory.\n" +\
        #        "D to open Drop menu.\nP to pause and unpause.\nC to open Character information screen.\n> to go down stairs.\n" +\
        #        "Mouse over a tile to see what is on it, either monsters or items.\n", [], SCREEN_WIDTH/2)
        elif choice == 2: #quit
            break
Пример #7
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)
Пример #8
0
def render_bar(x, y, total_width, name, value, maximum, bar_color, back_color):  # render a bar (HP, experience, etc).
    # first calculate the width of the bar
    bar_width = int(float(value) / maximum * total_width)
    # render the background first
    libtcod.console_set_background_color(panel, back_color)
    libtcod.console_rect(panel, x, y, total_width, 1, False)
    # now render the bar on top
    libtcod.console_set_background_color(panel, bar_color)
    if bar_width > 0:
        libtcod.console_rect(panel, x, y, bar_width, 1, False)
     # finally, some centered text with the values
    libtcod.console_set_foreground_color(panel, libtcod.white)
    libtcod.console_print_center(panel, x + total_width / 2, y, libtcod.BKGND_NONE, name + ': ' + str(value) + '/' + str(maximum))
    # show the player's stats
    libtcod.console_set_foreground_color(con, libtcod.white)
    libtcod.console_print_left(con, 1, SCREEN_HEIGHT - 2, libtcod.BKGND_NONE, 'HP: ' + str(player.fighter.hp) + '/' + str(player.fighter.max_hp) +'   ')
Пример #9
0
def render_bar(x, y, total_width, name, value, maximum, bar_color, back_color):
	float_value = float(value)
	float_max = float(maximum)
	bar_width = int((float_value/float_max)*total_width)

	#bar_width = int((float(value)/maximum) * total_width)

	libtcod.console_set_background_color(panel, back_color)
	libtcod.console_rect(panel, x, y, total_width, 1, False)

	libtcod.console_set_background_color(panel, bar_color)
	if bar_width > 0:
		libtcod.console_rect(panel, x, y, bar_width, 1, False)

	libtcod.console_set_foreground_color(panel, libtcod.white)
	libtcod.console_print_center(panel, x + total_width/2, y, libtcod.BKGND_NONE, name + ': ' + str(value) + '/' + str(maximum))
Пример #10
0
def renderBar(x, y, total_width, name, value, maximum, barColor, backColor):
    #Renders a status bar, first we calculate the width of it
    bar_width = int(float(value) / maximum * total_width)

    #render the background
    libtcod.console_set_background_color(panel, backColor)
    libtcod.console_rect(panel, x, y, total_width, 1, False)

    #Now render the top of the bar
    libtcod.console_set_background_color(panel, barColor)
    if bar_width > 0:
        libtcod.console_rect(panel, x, y, bar_width, 1, False)

    #text to denote what the bar is of
    libtcod.console_set_foreground_color(panel, libtcod.white)
    libtcod.console_print_center(panel, x + total_width/2, y, libtcod.BKGND_NONE,
        name + ": " + str(value) + "/" + str(maximum))
Пример #11
0
def render_bar(x, y, total_width, name, value, maximum, bar_color, back_color):
    #render a bar (HP, experience, etc). first calculate the width of the bar
    bar_width = int(float(value) / maximum * total_width)
 
    #render the background first
    libtcod.console_set_background_color(panel, back_color)
    libtcod.console_rect(panel, x, y, total_width, 1, False)
 
    #now render the bar on top
    libtcod.console_set_background_color(panel, bar_color)
    if bar_width > 0:
        libtcod.console_rect(panel, x, y, bar_width, 1, False)
 
    #finally, some centered text with the values
    libtcod.console_set_foreground_color(panel, libtcod.black)
    libtcod.console_print_center(panel, x + total_width / 2, y, libtcod.BKGND_NONE,
        name + ': ' + str(value) + '/' + str(maximum))
Пример #12
0
def render_bar(x, y, total_width, name, value, maximum, bar_color, back_color):
    float_value = float(value)
    float_max = float(maximum)
    bar_width = int((float_value / float_max) * total_width)

    #bar_width = int((float(value)/maximum) * total_width)

    libtcod.console_set_background_color(panel, back_color)
    libtcod.console_rect(panel, x, y, total_width, 1, False)

    libtcod.console_set_background_color(panel, bar_color)
    if bar_width > 0:
        libtcod.console_rect(panel, x, y, bar_width, 1, False)

    libtcod.console_set_foreground_color(panel, libtcod.white)
    libtcod.console_print_center(panel, x + total_width / 2, y,
                                 libtcod.BKGND_NONE,
                                 name + ': ' + str(value) + '/' + str(maximum))
Пример #13
0
def renderBar(x, y, total_width, name, value, maximum, barColor, backColor):
    #Renders a status bar, first we calculate the width of it
    bar_width = int(float(value) / maximum * total_width)

    #render the background
    libtcod.console_set_background_color(panel, backColor)
    libtcod.console_rect(panel, x, y, total_width, 1, False)

    #Now render the top of the bar
    libtcod.console_set_background_color(panel, barColor)
    if bar_width > 0:
        libtcod.console_rect(panel, x, y, bar_width, 1, False)

    #text to denote what the bar is of
    libtcod.console_set_foreground_color(panel, libtcod.white)
    libtcod.console_print_center(panel, x + total_width / 2, y,
                                 libtcod.BKGND_NONE,
                                 name + ": " + str(value) + "/" + str(maximum))
Пример #14
0
def render_bar(x, y, total_width, name, value, maximum, bar_color, back_color):
    #render a bar for tracking something. First comes width.
    bar_width = int(float(value) / maximum * total_width)

    #render the background first
    libtcod.console_set_background_color(panel, back_color)
    libtcod.console_rect(panel, x, y, total_width, 1, False)

    #Now render the bar on top
    libtcod.console_set_background_color(panel, bar_color)
    if bar_width > 0:
        libtcod.console_rect(panel, x, y, bar_width, 1, False)

    #And some centered text with values for clarity
    libtcod.console_set_foreground_color(panel, libtcod.white)
    libtcod.console_print_center(panel, x + total_width / 2, y,
                                 libtcod.BKGND_NONE,
                                 name + ': ' + str(value) + '/' + str(maximum))
Пример #15
0
def render_bar(x, y, total_width, name, value, maximum, bar_color, back_color):
    global panel

    # render a bar (HP, experience, etc). First calculate the width of the bar
    bar_width = int(float(value) / maximum * total_width)

    # render the background first
    libtcod.console_set_background_color(panel, back_color)
    libtcod.console_rect(panel, x, y, total_width, 1, False)

    # now render the bar on top
    libtcod.console_set_background_color(panel, bar_color)
    if bar_width > 0:
        libtcod.console_rect(panel, x, y, bar_width, 1, False)

    # finally, some centered text with the values
    libtcod.console_set_foreground_color(panel, libtcod.white)
    libtcod.console_print_center(panel, x + total_width / 2, y,
                                 libtcod.BKGND_NONE,
                                 name + ': ' + str(value) + '/' + str(maximum))
Пример #16
0
def main_menu():
    # img = libtcod.image_load('menu_background.png')
 
    # while not libtcod.console_is_window_closed():
        #show the background image, at twice the regular console resolution
        # libtcod.image_blit_2x(img, 0, 0, 0)
 
        #show the game's title, and some credits!
        libtcod.console_set_foreground_color(0, libtcod.light_yellow)
        libtcod.console_print_center(0, SCREEN_WIDTH/2, SCREEN_HEIGHT/2-4, libtcod.BKGND_NONE, 'Zombies!')
        libtcod.console_print_center(0, SCREEN_WIDTH/2, SCREEN_HEIGHT-2, libtcod.BKGND_NONE, 'By Glenn Jackson')
 
        #show options and wait for the player's choice
        choice = menu('', ['Play a new game'], 24)

	
        if choice == 0:  #new game
            new_game()
            play_game()
		
        else:
            new_game()
            play_game()
Пример #17
0
def mainMenu():
    image = libtcod.image_load("menu_background1.png")

    while not libtcod.console_is_window_closed():
        #Shows the background image
        libtcod.image_blit_2x(image, 0, 0, 0)

        #shows the game title and author
        libtcod.console_set_foreground_color(0, libtcod.light_orange)
        libtcod.console_print_center(0, SCREEN_WIDTH / 2,
                                     SCREEN_HEIGHT / 2 - 5, libtcod.BKGND_NONE,
                                     "Jules Quest")
        libtcod.console_print_center(0, SCREEN_WIDTH / 2,
                                     SCREEN_HEIGHT / 2 - 3, libtcod.BKGND_NONE,
                                     "By Julian Jocque")

        menuOptions = ["New Game", "Continue", "Quit"]
        #shows options and waits for a choice

        choice = menu("", menuOptions, MAIN_MENU_WIDTH)

        if choice == 0:  #new game
            newGame()
            playGame()
        elif choice == 1:  #continue
            try:
                loadGame()
                playGame()
            except:
                msgBox("\n No save file found.\n", MAIN_MENU_WIDTH)
                continue
        #elif choice == 2: #show instructions
        #    menu("\nArrow Keys to move and attack monsters.\nG to pickup an item you are standing on.\nI to open Inventory.\n" +\
        #        "D to open Drop menu.\nP to pause and unpause.\nC to open Character information screen.\n> to go down stairs.\n" +\
        #        "Mouse over a tile to see what is on it, either monsters or items.\n", [], SCREEN_WIDTH/2)
        elif choice == 2:  #quit
            break
Пример #18
0
Файл: game.py Проект: scgs/tbfch
def main_menu():
    while not libtcod.console_is_window_closed():
        # show the game's title, and some credits!
        libtcod.console_set_foreground_color(0, libtcod.light_yellow)
        libtcod.console_print_center(
            0, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 - 4, libtcod.BKGND_NONE, "The Battle For Cuyler Hall"
        )
        libtcod.console_print_center(0, SCREEN_WIDTH / 2, SCREEN_HEIGHT - 2, libtcod.BKGND_NONE, "By Gilgi")

        # show options and wait for the player's choice
        choice = menu("", ["Play a new game", "Continue last game", "Quit"], 24)

        if choice == 0:  # new game
            new_game()
            play_game()
        if choice == 1:  # load last game
            try:
                load_game()
            except:
                msgbox("\n No saved game to load.\n", 24)
                continue
            play_game()
        elif choice == 2:  # quit
            break
Пример #19
0
def main_menu():
	img = libtcod.image_load('moon.png')

	while not libtcod.console_is_window_closed():
		libtcod.image_blit_2x(img, 0, 0, 0)

		libtcod.console_set_foreground_color(0, libtcod.light_yellow)
		libtcod.console_print_center(0, SCREEN_WIDTH/2, (SCREEN_WIDTH/2)-4, libtcod.BKGND_NONE, 'Moon Game')
		libtcod.console_print_center(0, SCREEN_WIDTH/2, SCREEN_HEIGHT-2, libtcod.BKGND_NONE, 'James Disley')

		choice = menu('', ['Play a new game', 'Continue last game', 'Quit'], 24)

		if choice == 0:
			new_game()
			play_game()
		if choice == 1:
			try:
				load_game()
			except:
				msgbox('\n No saved game to load.\n', 24)
				continue
			play_game()
		elif choice == 2:
			break
Пример #20
0
def whole_number_menu(var, title, min_var=None):
    """A menu to change the value of a whole number x"""
    w, h = SCREEN_WIDTH, SCREEN_HEIGHT
    window = tcod.console_new(w, h)
    key = tcod.console_check_for_keypress()
    while not key.vk in (tcod.KEY_ENTER, tcod.KEY_ESCAPE):
        tcod.console_clear(window)
        x = SCREEN_WIDTH / 2
        y = SCREEN_HEIGHT / 2
        tcod.console_set_foreground_color(window, tcod.yellow)
        tcod.console_print_center(window, x, y, tcod.BKGND_NONE, title)
        tcod.console_set_foreground_color(window, tcod.white)
        tcod.console_print_center(window, x, y + 2, tcod.BKGND_NONE, str(var))

        tcod.console_set_foreground_color(window, tcod.grey)
        tcod.console_print_center(window, x, y + 4, tcod.BKGND_NONE,
                                  'Use arrows or number keys')
        tcod.console_print_center(window, x, y + 5, tcod.BKGND_NONE,
                                  'Press Enter or Escape to return')
        tcod.console_blit(window, 0, 0, w, h, 0, 0, 0, 1.0, 1.0)
        tcod.console_flush()

        key = tcod.console_wait_for_keypress(True)

        if key.vk == tcod.KEY_LEFT:
            # conway speed can update every frame at fastest
            var = max(var - 1, 1)
        elif key.vk == tcod.KEY_BACKSPACE:
            string_var = str(var)[:-1]
            if string_var == '':
                var = 0
            else:
                var = int(string_var)
        elif key.vk in number_keys:
            str_number = str(number_keys.index(key.vk))
            var = int(str(var) + str_number)
        elif key.vk == tcod.KEY_RIGHT:
            var += 1
    if min_var is None or var >= min_var:
        return var
    else:
        return whole_number_menu(var, title, min_var)
Пример #21
0
map_con = libtcod.console_new(MAP_WIDTH, MAP_HEIGHT)
panel = libtcod.console_new(SCREEN_WIDTH, PANEL_HEIGHT)
game_over = libtcod.console_new(MAP_WIDTH, MAP_HEIGHT)
inv_con = libtcod.console_new(INVENTORY_WIDTH, MAP_HEIGHT)

inv_open = False
inventory = []
inv_select = 0

took_turn = False

libtcod.console_set_background_color(game_over, libtcod.black)
libtcod.console_clear(game_over)
libtcod.console_set_foreground_color(game_over, libtcod.white)
libtcod.console_print_center(game_over, MAP_WIDTH/2, MAP_HEIGHT/2, libtcod.BKGND_NONE, 'Game Over')

experience = 0
dungeon_level = 1

blotter = [[('You awaken in a mysterious dungeon.',libtcod.white)]]

def descend():
    global blotter
    global creatures
    global items
    global dungeon_level

    dungeon_level += 1
    creatures = [player]
    items = []
Пример #22
0
def handle_main_menu():
    # default players
    players = [game.Player((0, 0), (1, 0), tcod.red,
                           controls=controls[0]),
               game.Player((-1, -1), (-1, 0),
                           tcod.cyan),  # cyan is used instead of blue for
               # legibility and brightness
               game.Player((-1, 0), (0, 1),
                           tcod.green),
               game.Player((0, -1), (0, -1),
                           tcod.yellow),
               ]

    conway_speed = CONWAY_SPEED
    map_width, map_height = SCREEN_SIZE
    max_fps = MAX_FPS

    while not tcod.console_is_window_closed():
        tcod.console_clear(0)
        tcod.console_set_foreground_color(0, tcod.white)
        tcod.console_print_center(0, SCREEN_WIDTH / 2, 2, tcod.BKGND_NONE,
                                  'Conway\'s Game of Tron')
        tcod.console_set_foreground_color(0, tcod.grey)
        tcod.console_print_center(0, SCREEN_WIDTH / 2, 3, tcod.BKGND_NONE,
                                  'by Spferical ([email protected])')
        tcod.console_print_center(0, SCREEN_WIDTH / 2, 4, tcod.BKGND_NONE,
                                  'Version ' + VERSION)
        tcod.console_set_foreground_color(0, tcod.white)
        tcod.console_print_left(0, 2, 6, tcod.BKGND_NONE,
                                '(a) Play')
        tcod.console_print_left(0, 2, 7, tcod.BKGND_NONE,
                                '(b) Exit')
        player_keys = ['c', 'd', 'e', 'f']
        y = 9
        x = 2
        playernum = -1
        for player in players:
            y += 1
            playernum += 1
            k = player_keys[playernum]
            if not player.dead:
                tcod.console_set_foreground_color(0, player.color)
            else:
                tcod.console_set_foreground_color(0, tcod.white)
            if not player.dead and player.controls:
                if player.controls == [tcod.KEY_UP, tcod.KEY_LEFT,
                                       tcod.KEY_DOWN, tcod.KEY_RIGHT]:
                    str_controls = '[arrow keys]'
                else:
                    str_controls = str(player.controls)
                text = '(' + k + ') ' + str(playernum +
                                            1) + ' Player ' + str_controls
            elif not player.dead and not player.controls:
                text = '(' + k + ') ' + str(playernum + 1) + ' CPU'
            else:
                text = '(' + k + ') ' + str(playernum + 1) + ' Not Playing'
            tcod.console_print_left(0, x, y, tcod.BKGND_NONE, text)

        tcod.console_set_foreground_color(0, tcod.white)
        tcod.console_print_left(0, 2, 15, tcod.BKGND_NONE,
                                '(g) Conway speed: ' + str(conway_speed))
        tcod.console_print_left(0, 2, 17, tcod.BKGND_NONE,
                                '(h) Map width: ' + str(map_width))
        tcod.console_print_left(0, 2, 18, tcod.BKGND_NONE,
                                '(i) Map height: ' + str(map_height))
        tcod.console_print_left(0, 2, 20, tcod.BKGND_NONE,
                                '(j) FPS: ' + str(max_fps))

        tcod.console_flush()

        raw_key = tcod.console_wait_for_keypress(tcod.KEY_PRESSED)
        key = get_key(raw_key)
        if key == 'a':
            game.play(copy.deepcopy(players), conway_speed,
                     (map_width, map_height), max_fps)
        elif key == 'b':
            break
        elif key in player_keys:
            p = player_keys.index(key)
            player = players[p]
            if player.dead:
                player.dead = False
                player.controls = controls[p]
            elif player.controls:
                player.controls = None
            else:
                player.dead = True
        elif key == 'g':
            conway_speed = whole_number_menu(
                conway_speed, 'The Conway simulation will update every how many frames?')
        elif key == 'h':
            map_width = whole_number_menu(
                map_width, 'How wide should the map be?', min_var=1)
        elif key == 'i':
            map_height = whole_number_menu(
                map_height, 'How tall should the map be?', min_var=1)
        elif key == 'j':
            max_fps = whole_number_menu(
                max_fps, 'How many frames per second should the game run at?')
        elif key == tcod.KEY_ESCAPE:
            break
Пример #23
0
def display_message_log(player):
	message_log_console = libtcod.console_new(80, 40)
	
	start_on_line = 0
	focus = 0
	n_messages = len(player.message_log)
	
	while True:
		# draw the log
		libtcod.console_clear(message_log_console)
		
		libtcod.console_set_foreground_color(message_log_console, libtcod.white)
		libtcod.console_print_center(message_log_console, 40, 1, libtcod.BKGND_NONE, 'Message Log')
		
		offset = 3
		line_n = 0
		
		focus_age = player.message_log[focus].age
		focus_drawn = False
		
		try:
			for n, message in enumerate(player.message_log):
				for line, text in enumerate(wrap_text(message.text, 75, subsequent_indent = ' ')):
					if line_n < start_on_line:
						line_n += 1
						
						if n == focus:
							raise FocusAboveScreen()
						
						continue
					
					if message.age == focus_age:
						shade = 1
					
					else:
						shade = 0.5
					
					libtcod.console_set_foreground_color(message_log_console, libtcod.white * shade)
					
					if line == 0:
						
						if n == focus:
							libtcod.console_put_char_ex( message_log_console, 0, offset, libtcod.CHAR_ARROW_E, libtcod.white, libtcod.black)
						
						if message.symbol1:
							libtcod.console_put_char_ex( message_log_console, (message.symbol2 is None) and 2 or 1, offset, message.symbol1[0], message.symbol1[1] * shade, message.symbol1[2] * shade )
						
						if message.symbol2:
							libtcod.console_put_char_ex( message_log_console, 2, offset, message.symbol2[0], message.symbol2[1] * shade, message.symbol2[2] * shade )
					
					parsed_text, parse_data = parse_colors(text)
					libtcod.console_print_left(message_log_console, 4, offset, libtcod.BKGND_NONE, parsed_text%parse_data)
					offset += 1
					
					if offset >= 39:
						if focus_drawn:
							raise LogIsFull()
						
						else:
							raise FocusBelowScreen()
				
				if n == focus:
					focus_drawn = True
		
		except LogIsFull:
			pass
		
		except FocusAboveScreen:
			start_on_line = max(0, start_on_line - 35)
			continue
		
		except FocusBelowScreen:
			start_on_line += 35
			continue
		
		libtcod.console_blit(message_log_console, 0, 0, 80, 40, 0, 0, 0)
		
		draw_hud(player)
		
		libtcod.console_flush()
		
		# wait for input
		key = libtcod.console_wait_for_keypress(True)
		
		if key.vk == libtcod.KEY_ESCAPE or key.c == ord('m'):
			break
		
		elif key.vk in DIRECTION_KEYS and DIRECTION_KEYS[key.vk][0] == 0:
			focus += DIRECTION_KEYS[key.vk][1]
			focus %= n_messages
	
	libtcod.console_delete(message_log_console)