Beispiel #1
0
def render_all(con, panel, entities, player, game_map, fov_map, fov_recompute, message_log, screen_width, screen_height,
               bar_width, panel_height, panel_y, mouse, colors, game_state):

    if fov_recompute:
        for y in range(game_map.height):
            for x in range(game_map.width):
                visible = libtcod.map_is_in_fov(fov_map, x, y)
                wall = game_map.tiles[x][y].block_sight

                if visible:
                    if wall:
                        libtcod.console_put_char_ex(con, x, y, '#', colors.lgray(), colors.black())
                    else:
                        libtcod.console_put_char_ex(con, x, y, '+', colors.dgray(), colors.black())
                    game_map.tiles[x][y].explored = True

                elif game_map.tiles[x][y].explored:
                    if wall:
                        libtcod.console_put_char_ex(con, x, y, '#', colors.dgray(), colors.black())
                    else:
                        libtcod.console_put_char_ex(con, x, y, '+', colors.black(), colors.black())

    entities_in_render_order = sorted(entities, key=lambda x: x.render_order.value)

    for entity in entities_in_render_order:
        draw_entity(con, entity, fov_map, game_map)

    libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)

    libtcod.console_set_default_background(panel, colors.black())
    libtcod.console_clear(panel)

    y = 1
    for message in message_log.messages:
        libtcod.console_set_default_foreground(panel, message.color)
        libtcod.console_print_ex(panel, message_log.x, y, libtcod.BKGND_NONE, libtcod.LEFT, message.text)
        y += 1

    render_bar(panel, 1, 1, bar_width, 'HP', player.fighter.hp, player.fighter.max_hp,
               colors.red(), colors.dred(), colors.white())
    libtcod.console_print_ex(panel, 1, 3, libtcod.BKGND_NONE, libtcod.LEFT,
                             'Dungeon level: {0}'.format(game_map.dungeon_level))

    libtcod.console_set_default_foreground(panel, colors.lgray())
    libtcod.console_print_ex(panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT,
                             get_names_under_mouse(mouse, entities, fov_map))

    libtcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0, panel_y)
    
    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
            inventory_title = 'Press the key next to an item to use it, or Esc to cancel.\n'
        else:
            inventory_title = 'Press the key next to an item to drop it, or Esc to cancel.\n'

        inventory_menu(con, inventory_title, player, 50, screen_width, screen_height)
    elif game_state == GameStates.LEVEL_UP:
        level_up_menu(con, 'Level up! Choose a stat to raise:', player, 40, screen_width, screen_height)
    elif game_state == GameStates.CHARACTER_SCREEN:
        character_screen(player, 30, 18, screen_width, screen_height)
Beispiel #2
0
def render_all(con, panel, entities, player, game_map, fov_map, fov_recompute, message_log, screen_width, screen_height, bar_width, panel_height, panel_y, mouse, colors, game_state):
	# Draw all the tiles in the game map
	if fov_recompute:
		for y in range(game_map.height):
			for x in range(game_map.width):
				visible = libtcod.map_is_in_fov(fov_map, x, y)
				wall = game_map.tiles[x][y].block_sight

				if visible:
					if wall:
						libtcod.console_set_char_background(con, x, y, colors.get('light_wall'), libtcod.BKGND_SET)
					else:
						libtcod.console_set_char_background(con, x, y, colors.get('light_ground'), libtcod.BKGND_SET)

					game_map.tiles[x][y].explored = True

				elif game_map.tiles[x][y].explored:
					if wall:
						libtcod.console_set_char_background(con, x, y, colors.get('dark_wall'), libtcod.BKGND_SET)
					else:
						libtcod.console_set_char_background(con, x, y, colors.get('dark_ground'), libtcod.BKGND_SET)   
	
	entities_in_render_order = sorted(entities, key=lambda x: x.render_order.value)
	# Draw all entities in the list
	for entity in entities_in_render_order:
		draw_entity(con, entity, fov_map, game_map)

	libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)

	libtcod.console_set_default_background(panel, libtcod.black)
	libtcod.console_clear(panel)

	#Print the game messages, one line at a time
	y = 1
	for message in message_log.messages:
		libtcod.console_set_default_foreground(panel, message.color)
		libtcod.console_print_ex(panel, message_log.x, y, libtcod.BKGND_NONE, libtcod.LEFT, message.text)
		y += 1

	render_bar(panel, 1, 1, bar_width, 'HP', player.fighter.hp, player.fighter.max_hp, libtcod.light_red, libtcod.darker_red)

	libtcod.console_print_ex(panel, 1, 3, libtcod.BKGND_NONE, libtcod.LEFT, 'Dungeon level: {0}'.format(game_map.dungeon_level))

	libtcod.console_set_default_foreground(panel, libtcod.light_gray)
	libtcod.console_print_ex(panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT, get_names_under_mouse(mouse, entities, fov_map))
	libtcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0, panel_y)

	if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
		if game_state == GameStates.SHOW_INVENTORY:
			inventory_title = 'Press the key next to the item to use it, or Esc to cancel.\n'
		else:
			inventory_title = 'Press the key next to an item to drop it, or Esc to cancel.\n'

		inventory_menu(con, inventory_title, player.inventory, 50, screen_width, screen_height)

	elif game_state == GameStates.LEVEL_UP:
		level_up_menu(con, 'Level up! Choose a stat to raise:', player, 40, screen_width, screen_height)

	elif game_state == GameStates.CHARACTER_SCREEN:
		character_screen(player, 30, 10, screen_width, screen_height)
Beispiel #3
0
    def render_menus(self, player, game_state, world_map=None):
        if game_state in (GameStates.SHOW_INVENTORY,
                          GameStates.DROP_INVENTORY):
            if game_state == GameStates.SHOW_INVENTORY:
                inventory_title = menu_vars.inventory_show_title
            else:
                inventory_title = menu_vars.inventory_drop_title

            inventory_menu(inventory_title, menu_vars.inventory_width, player,
                           self)
        elif game_state == GameStates.LEVEL_UP:
            level_up_menu(menu_vars.level_up_title, menu_vars.level_up_width,
                          player, self)
        elif game_state == GameStates.CHARACTER_SCREEN:
            character_screen(player, menu_vars.character_screen_width,
                             menu_vars.character_screen_height, self)
        elif game_state == GameStates.SHOW_LOCATIONS:
            tile = world_map.tiles[player.x][player.y]
            locations_menu(menu_vars.location_list_title,
                           menu_vars.location_list_width, tile.locations, self)
        elif game_state == GameStates.EXPLORATION_SCREEN:
            tile = world_map.tiles[player.x][player.y]
            dx, dy = world_map.potential_move
            exploration_screen(player, menu_vars.exploration_screen_width,
                               menu_vars.exploration_screen_height, world_map,
                               (player.x + dx, player.y + dy), self)
def render_all(con, panel, entities, player, game_map, fov_map, fov_recompute, message_log, screen_width,
                 screen_height, bar_width, panel_height, panel_y, mouse, colors, game_state):
    # Draw all the tiles in the game map
    if fov_recompute:
        for y in range(game_map.height):
            for x in range(game_map.width):
                visible = libtcod.map_is_in_fov(fov_map, x, y)
                wall = game_map.tiles[x][y].block_sight

                if visible:
                    if wall:
                        libtcod.console_set_char_background(con, x, y, colors.get('light_wall'), libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_char_background(con, x, y, colors.get('light_ground'), libtcod.BKGND_SET)
                    
                    game_map.tiles[x][y].explored = True
                elif game_map.tiles[x][y].explored:
                    if wall:
                        libtcod.console_set_char_background(con, x, y, colors.get('dark_wall'), libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_char_background(con, x, y, colors.get('dark_ground'), libtcod.BKGND_SET)


    # Draw all entities in the list
    entities_in_render_order = sorted(entities, key=lambda x: x.render_order.value)

    for entity in entities_in_render_order:
        draw_entity(con, entity, fov_map)
    

    libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)

    libtcod.console_set_default_background(panel, libtcod.black)
    libtcod.console_clear(panel)

    # Print the game messages, one line at a time
    y = 1
    for message in message_log.messages:
        libtcod.console_set_default_foreground(panel, message.color)
        libtcod.console_print_ex(panel, message_log.x, y, libtcod.BKGND_NONE, 
                                libtcod.LEFT, message.text)
        y +=1

    render_bar(panel, 1, 1, bar_width, 'HP', player.fighter.hp, player.fighter.max_hp,
                libtcod.light_red, libtcod.darker_red)

    libtcod.console_set_default_foreground(panel, libtcod.light_gray)
    libtcod.console_print_ex(panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT,
                            get_names_under_mouse(mouse, entities, fov_map))

    libtcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0, panel_y)

    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
            inventory_title = 'Press the key next to an item to use it, or Esc to cancel.\n'
        else:
            inventory_title = 'Press the key next to an item to drop it, or Esc to cancel.\n'
                
        inventory_menu(con, inventory_title, player.inventory, 50, screen_width, screen_height)
Beispiel #5
0
def render_all(con, panel, entities, player, game_map, fov_map, fov_recompute, message_log, screen_width, screen_height,
               bar_width, panel_height, panel_y, mouse, colors, game_state):

    if fov_recompute:
    # Draw all the tiles in the game map
    
        for y in range(game_map.height):
            for x in range(game_map.width):
                visible = libtcod.map_is_in_fov(fov_map, x, y)
                wall = game_map.tiles[x][y].block_sight

                if visible:
                    if wall:
                        libtcod.console_set_char_background(con, x, y, colors.get('light_wall'), libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_char_background(con, x, y, colors.get('light_ground'), libtcod.BKGND_SET)

                    game_map.tiles[x][y].explored = True
                elif game_map.tiles[x][y].explored:
                    if wall:
                        libtcod.console_set_char_background(con, x, y, colors.get('dark_wall'), libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_char_background(con, x, y, colors.get('dark_ground'), libtcod.BKGND_SET)

    entities_in_render_order = sorted(entities, key=lambda x: x.render_order.value)

    # Draw all entities in the list
    for entity in entities_in_render_order:
        draw_entity(con, entity, fov_map)

    #UI rendering;

    libtcod.console_set_default_background(con, libtcod.black)
    libtcod.console_set_default_foreground(con, libtcod.white)
    
    libtcod.console_print_ex(con, 1, 1, libtcod.BKGND_NONE, libtcod.LEFT, "Depth;")
    libtcod.console_print_ex(con, 1, 2, libtcod.BKGND_NONE, libtcod.LEFT, str(player.depth))

    libtcod.console_print_ex(con, 1, 4, libtcod.BKGND_NONE, libtcod.LEFT, "Score;")
    libtcod.console_print_ex(con, 1, 5, libtcod.BKGND_NONE, libtcod.LEFT, str(player.score))

    # 'frame' for item icons
    #libtcod.console_print_ex(con, 36, 1, libtcod.BKGND_NONE, libtcod.LEFT, "123")
    #libtcod.console_print_ex(con, 36, 2, libtcod.BKGND_NONE, libtcod.LEFT, "4 4")
    #libtcod.console_print_ex(con, 36, 3, libtcod.BKGND_NONE, libtcod.LEFT, "526")
    
    libtcod.console_set_default_foreground(con, libtcod.dark_gray)
    libtcod.console_print_ex(con, 31, 38, libtcod.BKGND_NONE, libtcod.LEFT, "Tartarus")
    
    libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)
  

    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
            inventory_title = 'Press the key next to an item to use it, or Esc to cancel.\n'
        else:
            inventory_title = 'Press the key next to an item to drop it, or Esc to cancel.\n'

        inventory_menu(con, inventory_title, player.inventory, 50, screen_width, screen_height)
def render_all(con, panel, entities, player, game_map, fov_map, fov_recompute, message_log, screen_width, screen_height,  bar_width, panel_height, panel_y, mouse, colors, game_state):
	if fov_recompute:
		#Draw all tiles in the game map
		for x in range(game_map.width):
			for y in range(game_map.height):
				visible = libtcod.map_is_in_fov(fov_map, x, y)
				isWall = game_map.tiles[x][y].block_sight
				
				if visible:
					if isWall:
						libtcod.console_set_char_background(con, x, y, colors.get('light_wall'), libtcod.BKGND_SET)
					else:
						libtcod.console_set_char_background(con, x, y, colors.get('light_ground'), libtcod.BKGND_SET)
					game_map.tiles[x][y].explored = True
				elif game_map.tiles[x][y].explored:
					if isWall:
						libtcod.console_set_char_background(con, x, y, colors.get('dark_wall'), libtcod.BKGND_SET)
					else:
						libtcod.console_set_char_background(con, x, y, colors.get('dark_ground'), libtcod.BKGND_SET)
	
	entities_in_render_order = sorted(entities, key=lambda x: x.render_order.value)
	
	#Draws all entities in the list
	for entity in entities_in_render_order:
		draw_entity(con, entity, fov_map, game_map)
	
	libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)
	
	#Draw the information panel		
	libtcod.console_set_default_background(panel, libtcod.black)
	libtcod.console_clear(panel)
	
	y = 1
	for message in message_log.messages:
		libtcod.console_set_default_foreground(panel, message.color)
		libtcod.console_print_ex(panel, message_log.x, y, libtcod.BKGND_NONE, libtcod.LEFT, message.text)
		y += 1
		
	render_bar(panel, 1, 1, bar_width, 'HP', player.fighter.hp, player.fighter.max_hp, libtcod.light_red, libtcod.darker_red)
	
	libtcod.console_print_ex(panel, 1, 3, libtcod.BKGND_NONE, libtcod.LEFT, 'Dungeon Level: {0}'.format(game_map.dungeon_level)) 
	
	libtcod.console_set_default_foreground(panel, libtcod.light_gray)
	libtcod.console_print_ex(panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT, get_names_under_mouse(mouse, entities, fov_map))
	
	libtcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0, panel_y)
	
	if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
		if game_state == GameStates.SHOW_INVENTORY:
			inventory_title = 'Press the key next to the item to use it, or esc to cancel\n'
		else:
			inventory_title = 'Press the key next to the item to drop it, or esc to cancel\n'
		inventory_menu(con, inventory_title, player, 50, screen_width, screen_height)
	
	elif game_state == GameStates.LEVEL_UP:
		level_up_menu(con, 'Level Up! Choose a state to raise:', player, 40, screen_width, screen_height)
		
	elif game_state == GameStates.CHARACTER_SCREEN:
		character_screen(player, 30, 10, screen_width, screen_height)
Beispiel #7
0
def render_menu(root: tcod.console.Console, player: Entity, screen_width: int,
                screen_height: int, game_state: GameStates):
    if game_state == GameStates.SHOW_INVENTORY:
        inventory_menu(root, 'Select an item to use', player.inventory, 50,
                       screen_width, screen_height)
    elif game_state is GameStates.DROP_INVENTORY:
        inventory_menu(root, 'Select an item to drop', player.inventory, 50,
                       screen_width, screen_height)
    return
Beispiel #8
0
def render_all(con, panel, entities, player, game_map, fov_map, fov_recompute,
               message_log, screen_width, screen_height, bar_width, panel_y,
               colors, root, game_state):
    if fov_recompute:
        for y in range(game_map.height):
            for x in range(game_map.width):
                visible = tcod.map_is_in_fov(fov_map, x, y)
                wall = game_map.tiles[x][y].block_sight
                if visible:
                    if wall:
                        tcod.console_set_char_background(
                            con, x, y, colors.get('light_wall'),
                            tcod.BKGND_SET)
                    else:
                        tcod.console_set_char_background(
                            con, x, y, colors.get('light_ground'),
                            tcod.BKGND_SET)
                    game_map.tiles[x][y].explored = True
                elif game_map.tiles[x][y].explored:
                    if wall:
                        tcod.console_set_char_background(
                            con, x, y, colors.get('dark_wall'), tcod.BKGND_SET)
                    else:
                        tcod.console_set_char_background(
                            con, x, y, colors.get('dark_ground'),
                            tcod.BKGND_SET)
    entities_in_render_order = sorted(entities,
                                      key=lambda _: _.render_order.value)
    for entity in entities_in_render_order:
        draw_entity(con, entity, fov_map, game_map)
    con.blit(root, 0, 0, 0, 0, screen_width, screen_height)
    panel.default_bg = tcod.black
    panel.clear()
    # Print the game messages, one line at a time
    y = 1
    for message in message_log.messages:
        panel.default_fg = message.color
        tcod.console_print_ex(panel, message_log.x, y, tcod.BKGND_NONE,
                              tcod.LEFT, message.text)
        y += 1
    render_bar(panel, 1, 1, bar_width, 'HP', player.fighter.hp,
               player.fighter.max_hp, tcod.darker_red, tcod.darker_gray)
    tcod.console_print_ex(panel, 1, 3, tcod.BKGND_NONE, tcod.LEFT,
                          'Dungeon level: {0}'.format(game_map.dungeon_level))
    panel.blit(root, 0, panel_y, 0, 0, screen_width, screen_height)
    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
            inventory_title = 'Press the key next to an item to use it, or Esc to cancel.\n'
        else:
            inventory_title = 'Press the key next to an item to drop it, or Esc to cancel.\n'
        inventory_menu(con, inventory_title, player.inventory, 50,
                       screen_width, screen_height, root)
    elif game_state == GameStates.CHARACTER_SCREEN:
        character_screen(player, 30, 10, screen_width, screen_height)
Beispiel #9
0
def render_all(con, panel, entities, player, game_map, fov_map, fov_recompute, message_log, screen_width, screen_height, bar_width, panel_height, mouse, colours, game_state):
    if fov_recompute:
        for y in range(game_map.height):
            for x in range(game_map.width):
                visible=tcod.map_is_in_fov(fov_map, x, y)
                wall=game_map.tiles[x][y].block_sight
                if visible:
                    if wall:
                        tcod.console_set_char_background(con, x, y, colours.get('light_wall'), tcod.BKGND_SET)
                    else:
                        tcod.console_set_char_background(con, x, y, colours.get('light_ground'), tcod.BKGND_SET)
                    game_map.tiles[x][y].explored=True
                elif game_map.tiles[x][y].explored:
                    if wall:
                        tcod.console_set_char_background(con, x, y, colours.get('dark_wall'), tcod.BKGND_SET)
                    else:
                        tcod.console_set_char_background(con, x, y, colours.get('dark_ground'), tcod.BKGND_SET)
    render_ordered_entities=sorted(entities, key=lambda x: x.render_order.value)
    for entity in render_ordered_entities:
        draw_entity(con, entity, fov_map)
    tcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)
    # HP bar
    tcod.console_set_default_background(panel, tcod.black)
    tcod.console_clear(panel)
    # Message log
    y=1
    for message in message_log.messages:
        tcod.console_set_default_foreground(panel, message.colour)
        tcod.console_print_ex(panel, message_log.x, y, tcod.BKGND_NONE, tcod.LEFT, message.text)
        y+=1
    render_bar(panel, 1, 1, bar_width, 'HP', player.combatant.health, player.combatant.max_hp, tcod.light_red, tcod.darker_red)
    tcod.console_print_ex(panel, 1, 3, tcod.BKGND_NONE, tcod.LEFT, 'Gungeon Depth: {0}'.format(game_map.depth))
    # Mouseover details
    tcod.console_set_default_foreground(panel, tcod.light_gray)
    tcod.console_print_ex(panel, 1, 0, tcod.BKGND_NONE, tcod.LEFT, get_names_mouseover(mouse, entities, fov_map))

    tcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0, screen_height-panel_height)
    # Taking inventory
    if game_state in (GameStates.INVENTORY, GameStates.DROP_INVENTORY):
        if game_state==GameStates.INVENTORY:
            title='Taking Inventory: Press Escape to escape.\n'
        else:
            title='Dropping Inventory: Press Escape to escape.\n'
        inventory_menu(con, title, player, 50, screen_width, screen_height)

    elif game_state==GameStates.LEVEL_UP:
        level_up_menu(con, 'Level up! Power you:', player, 40, screen_width, screen_height)

    elif game_state==GameStates.MIRROR:
        mirror_screen(player, 30, 10, screen_width, screen_height)
Beispiel #10
0
def render_all(con, panel, game_map, fov_map, fov_recompute, message_log,
               entities, screen_width, screen_height, colors, player,
               bar_width, panel_height, panel_y, mouse, game_state):

    if fov_recompute:
        #Draw tiles in map
        draw_map(con, game_map, fov_map, colors)

    entities_in_render_order = sorted(entities,
                                      key=lambda x: x.render_order.value)

    # Draw all entities in the list
    for entity in entities_in_render_order:
        draw_entity(con, entity, fov_map)

    libtcod.console_set_default_foreground(con, libtcod.white)
    libtcod.console_print_ex(
        con, 1, screen_height - 2, libtcod.BKGND_NONE, libtcod.LEFT,
        'HP: {0:02}/{1:02}'.format(player.fighter.hp, player.fighter.max_hp))

    libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)

    libtcod.console_set_default_background(panel, libtcod.black)
    libtcod.console_clear(panel)

    # Print the game messages, one line at a time
    y = 1
    for message in message_log.messages:
        libtcod.console_set_default_foreground(panel, message.color)
        libtcod.console_print_ex(panel, message_log.x, y, libtcod.BKGND_NONE,
                                 libtcod.LEFT, message.text)
        y += 1

    render_bar(panel, 1, 1, bar_width, 'HP', player.fighter.hp,
               player.fighter.max_hp, libtcod.light_red, libtcod.darker_red)

    libtcod.console_set_default_foreground(panel, libtcod.light_gray)
    libtcod.console_print_ex(panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT,
                             get_name_under_mouse(mouse, entities, fov_map))

    libtcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0,
                         panel_y)

    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
            inventory_title = 'Press the key next to an item to use it, or Esc to cancel. \n'
        else:
            inventory_title = 'Press the key next to an item to drop it, or Esc to cancel. \n'
        inventory_menu(con, inventory_title, player.inventory, 50,
                       screen_width, screen_height)
Beispiel #11
0
def render_menu_console(game_state, player, quest_request=None, exclude=[]):
    if game_state == GameStates.GAME_PAUSED:
        return game_paused()
    elif game_state == GameStates.GAME_OVER:
        return game_over()
    elif game_state == GameStates.GAME_COMPLETE:
        return game_completed()
    elif game_state == GameStates.CHARACTER_SCREEN:
        return character_screen(player)
    elif game_state in INVENTORY_STATES:
        if game_state == GameStates.INVENTORY_USE:
            inventory_title = 'Press the key next to an item to use it, or Esc to cancel.\n'
        elif game_state == GameStates.INVENTORY_EXAMINE:
            inventory_title = 'Press the key next to an item to examine it, or Esc to cancel.\n'
        elif game_state == GameStates.INVENTORY_DROP:
            inventory_title = 'Press the key next to an item to drop it, or Esc to cancel.\n'
        elif game_state == GameStates.INVENTORY_SELECT:
            inventory_title = 'Press the key next to an item to identify it, or Esc to cancel.\n'
        else:
            inventory_title = 'Esc to cancel.\n'

        return inventory_menu(inventory_title, player, exclude)
    elif game_state == GameStates.QUEST_ONBOARDING:
        return quest_menu(quest_request)
    elif game_state == GameStates.QUEST_LIST:
        return quest_list_menu(player)
    elif game_state == GameStates.LEVEL_UP:
        return level_up_menu(player)
Beispiel #12
0
def render_all(con, panel, entities, players, active_player, game_map, fov_recompute, message_log, screen_width, screen_height, bar_width,
					panel_height, panel_y, mouse, colors, game_state):
	if fov_recompute:
		render_map(con, players, game_map, screen_width, screen_height)
						
	# Draw all entities in the list
	render_entities(con, entities, players, game_map, screen_width, screen_height)

	# Render bars
	libtcod.console_set_default_background(panel, libtcod.black)
	libtcod.console_clear(panel)

	# Print the game messages, one line at a time
	y = 1
	for message in message_log.messages:
		libtcod.console_set_default_foreground(panel, message.color)
		libtcod.console_print_ex(panel, message_log.x, y, libtcod.BKGND_NONE, libtcod.LEFT, message.text)
		y +=1

	# Render HP and dungeon level
	for i in range(len(players)):
		render_bar(panel, 2, i+2, bar_width-1, 'HP', players[i].fighter.hp, players[i].fighter.max_hp,
				libtcod.red, libtcod.darker_red)
	# Print > next to active player
	libtcod.console_print_ex(panel, 1, active_player + 2, libtcod.BKGND_NONE, libtcod.LEFT, '>')
	libtcod.console_print_ex(panel, 1, 1, libtcod.BKGND_NONE, libtcod.LEFT,
							'Dungeon level: {0}'.format(game_map.dungeon_level))

	libtcod.console_set_default_foreground(panel, libtcod.light_gray)
	libtcod.console_print_ex(panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT,
							get_names_under_mouse(mouse, entities, game_map, players))

	libtcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0, panel_y)

	if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
		if game_state == GameStates.SHOW_INVENTORY:
			inventory_title = 'Press the key next to an item to use it, or Esc to cancel.\n'
		else:
			inventory_title = 'Press the key next to an item to drop it, or Esc to cancel.\n'
		
		inventory_menu(con, inventory_title, players[active_player], 50, screen_width, screen_height)

	elif game_state == GameStates.LEVEL_UP:
		level_up_menu(con, 'Level up! Choose a stat to raise:', players[active_player], 40, screen_width, screen_height)

	elif game_state == GameStates.CHARACTER_SCREEN:
		character_screen(players[active_player], 30, 10, screen_width, screen_height)
def render_all(entities: List[Entity], player: Entity, game_map: GameMap,
               game_state: GameStates, message_log: MessageLog, constants):
    # Draw the map
    game_map.current_floor.render(colors=constants['colors'])

    entities_in_render_order = sorted(entities,
                                      key=lambda x: x.render_order.value)

    # Draw all entities in the list
    for entity in entities_in_render_order:
        if game_map.current_floor.fov[entity.x, entity.y]:
            entity.draw()

    render_bar(x=81,
               y=1,
               total_width=30,
               label='HP',
               current_value=player.fighter.hp,
               maximum_value=player.fighter.max_hp,
               text_color='white',
               bar_primary_color='green',
               bar_secondary_color='red')

    terminal.printf(x=81,
                    y=3,
                    s=f'Dungeon Floor: {game_map.current_floor_number}')

    message_log.render()

    names_under_mouse = get_names_under_mouse(entities,
                                              game_map.current_floor.fov)

    if names_under_mouse:
        terminal.printf(81, 5, names_under_mouse)

    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
            inventory_title = 'Press the key next to an item to use it, or Esc to cancel.\n'
        else:
            inventory_title = 'Press the key next to an item to drop it, or Esc to cancel.\n'

        inventory_menu(header=inventory_title,
                       player=player,
                       inventory_width=50,
                       screen_width=constants['screen_width'],
                       screen_height=constants['screen_height'])
Beispiel #14
0
def render_all(con, panels, entities, player, game_map, fov, message_log,
               game_state, camera):
    camera.move_camera(player, fov)
    if fov.recompute:
        fov.recompute = False
        fov.recompute_fov(player)
        libtcod.console_clear(con)
        for y in range(camera.height):
            for x in range(camera.width):
                (map_x, map_y) = (int(camera.x + x), int(camera.y + y))
                visible = libtcod.map_is_in_fov(fov.map, map_x, map_y)
                wall = game_map.tiles[map_x][map_y].block_sight
                if visible:
                    if wall:
                        libtcod.console_set_char_background(
                            con, x, y, COLORS.get('light_wall'),
                            libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_char_background(
                            con, x, y, COLORS.get('light_ground'),
                            libtcod.BKGND_SET)
                    game_map.tiles[map_x][map_y].explored = True
                elif game_map.tiles[map_x][map_y].explored:
                    if wall:
                        libtcod.console_set_char_background(
                            con, x, y, COLORS.get('dark_wall'),
                            libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_char_background(
                            con, x, y, COLORS.get('dark_ground'),
                            libtcod.BKGND_SET)
    # Draw all entities in the list
    entities_in_render_order = sorted(entities, key=lambda x: x.render.value)
    for entity in entities_in_render_order:
        draw_entity(con, entity, fov.map, camera)
    libtcod.console_blit(con, 0, 0, con.width, con.height, 0, 0, 0)
    for panel in panels:
        panel.draw(message_log)
    if game_state == GameStates.SHOW_INVENTORY:
        inventory_menu(con, player.inventory, 50)
def render_all(source_con, dest_con, panel_con, entities_list, player, game_map, fov_map, fov_recompute, message_log, screen_width, screen_height, kolors, game_type, interface_skin, indoors, hp_bar_width, panel_height, panel_y, mouse, game_state):
    if indoors == True:
        render_all_indoors(source_con, dest_con, panel_con, entities_list, player, game_map, fov_map, fov_recompute, message_log, screen_width, screen_height, kolors, game_type, interface_skin, hp_bar_width, panel_height, panel_y, mouse)
    if indoors == False:
        render_all_outdoors(source_con, dest_con, panel_con, entities_list, player, game_map, fov_map, fov_recompute, message_log, screen_width, screen_height, kolors, game_type, interface_skin, hp_bar_width, panel_height, panel_y, mouse)

    #Draw all entities in the list
    entities_in_render_order = sorted(entities_list, key=lambda x: x.render_order.value)
    for entity in entities_in_render_order:
        draw_entity(source_con, entity, fov_map)

    #Overlay the source console onto the destination console
    source_con.blit(dest=dest_con, width=screen_width, height=screen_height)

    #Setup the panel console
    panel_con.default_bg = (tcod.black)
    tcod.console_clear(panel_con)

    #Print the game messages, one line at a time
    y = 1
    for message in message_log.messages:
        panel_con.print(x=message_log.x, y=y, string=message.text, fg=message.color, bg_blend=tcod.BKGND_NONE, alignment=tcod.LEFT)
        y += 1

    #Draw the HP counter
    render_bar(panel_con, 1, 1, hp_bar_width, 'HP', player.fighter.hp, player.fighter.max_hp, tcod.light_red, tcod.darker_red)

    #Write the name of the entity under the mouse cursor
    panel_con.print(x=1, y=0, string=get_names_under_mouse(mouse, entities_list, fov_map), fg=tcod.light_gray, bg_blend=tcod.BKGND_NONE, alignment=tcod.LEFT)

    #Overlay the panel console onto the destination console
    panel_con.blit(dest=dest_con, width=screen_width, height=panel_height, dest_y=panel_y)

    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
           inventory_title = 'Press item letter to use, or Esc to cancel.\n'
        else:
           inventory_title = 'Press item letter to drop it, or Esc to cancel.\n'

        inventory_menu(dest_con, inventory_title, player.inventory, 50, screen_width, screen_height)
Beispiel #16
0
def render_all(con, panel, entities, player, game_map, fov_map, fov_recompute,
               message_log, screen_width, screen_height, bar_width,
               panel_height, panel_y, mouse, colors, game_state):
    # draw all tiles in the game map
    # loop through each tile in the game map and check if it blocks sight or not
    if fov_recompute:
        for y in range(game_map.height):
            for x in range(game_map.width):
                visible = libtcod.map_is_in_fov(fov_map, x, y)
                wall = game_map.tiles[x][y].block_sight

                if visible:  # if tile is visible, it will be drawn in the "light" colors
                    # if blocks sight, draw as a wall
                    if wall:
                        libtcod.console_set_char_background(
                            con, x, y, colors.get('light_wall'),
                            libtcod.BKGND_SET)
                    # if does not block sight, draw as a floor
                    else:
                        libtcod.console_set_char_background(
                            con, x, y, colors.get('light_ground'),
                            libtcod.BKGND_SET)

                    # mark tiles within the player's field of view as explored
                    game_map.tiles[x][y].explored = True
                elif game_map.tiles[x][
                        y].explored:  # tile is not within FOV - however, if the tile has already been explored, draw it as a "dark" tile
                    # if blocks sight, draw as a wall
                    if wall:
                        libtcod.console_set_char_background(
                            con, x, y, colors.get('dark_wall'),
                            libtcod.BKGND_SET)
                    # if does not block sight, draw as a floor
                    else:
                        libtcod.console_set_char_background(
                            con, x, y, colors.get('dark_ground'),
                            libtcod.BKGND_SET)

    entities_in_render_order = sorted(entities,
                                      key=lambda x: x.render_order.value)

    # draw all entities in the list
    for entity in entities_in_render_order:
        draw_entity(con, entity, fov_map, game_map)

    libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)

    libtcod.console_set_default_background(panel, libtcod.black)
    libtcod.console_clear(panel)

    # print the game messages, one line at a time
    y = 1
    for message in message_log.messages:
        libtcod.console_set_default_foreground(panel, message.color)
        libtcod.console_print_ex(panel, message_log.x, y, libtcod.BKGND_NONE,
                                 libtcod.LEFT, message.text)
        y += 1

    render_bar(panel, 1, 1, bar_width, 'HP', player.fighter.hp,
               player.fighter.max_hp, libtcod.light_red, libtcod.darker_red)

    libtcod.console_print_ex(
        panel, 1, 3, libtcod.BKGND_NONE, libtcod.LEFT,
        'Dungeon level: {0}'.format(game_map.dungeon_level))

    libtcod.console_set_default_foreground(panel, libtcod.light_gray)
    libtcod.console_print_ex(panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT,
                             get_names_under_mouse(mouse, entities, fov_map))

    libtcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0,
                         panel_y)

    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
            inventory_title = 'Press the key next to an item to use it, or Esc to cancel.\n'
        else:
            inventory_title = 'Press the key next to an item to drop it, or Esc to cancel.\n'
        inventory_menu(con, inventory_title, player.inventory, 50,
                       screen_width, screen_height)

    elif game_state == GameStates.LEVEL_UP:
        level_up_menu(con, 'Level up! Choose a state to raise:', player, 40,
                      screen_width, screen_height)

    elif game_state == GameStates.CHARACTER_SCREEN:
        character_screen(player, 30, 10, screen_width, screen_height)
Beispiel #17
0
def render_all(game_state, con, panel, mouse, entities, player, game_map,
               fov_map, light_map, camera, message_log, fov_recompute,
               screen_width, screen_height, bar_width, panel_height, panel_y,
               colors):
    # fov 재계산 시만
    if fov_recompute:
        #tcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)
        con.clear()
        for y in range(game_map.height):
            for x in range(game_map.width):
                # 지도 위치
                Mapx = x + camera.x
                Mapy = y + camera.y

                #print(F"{camera.x},{camera.y}")

                # wall 불리언에 tile의 block_sight이 True인지 여부를 대입
                visible = fov_map.fov[y, x]
                wall = game_map.tiles[y, x].block_sight

                if light_map[y, x] == 999:
                    brightness = 0
                else:
                    brightness = light_map[y, x]

                if visible:
                    game_map.tiles[y, x].explored = True
                    if wall:
                        draw_background(con, Mapx, Mapy, 'light_wall',
                                        brightness)
                    else:
                        draw_background(con, Mapx, Mapy, 'light_ground',
                                        brightness)
                elif game_map.tiles[y, x].explored:
                    if wall:
                        draw_background(con, Mapx, Mapy, 'dark_wall')
                    else:
                        draw_background(con, Mapx, Mapy, 'dark_ground')
                else:
                    draw_background(con, Mapx, Mapy, 'pitch_black')

    # 목록에 있는 모든 객체를 표시함.
    entities_in_render_order = sorted(entities,
                                      key=lambda x: x.render_order.value)

    for entity in entities_in_render_order:
        draw_entity(con, entity, fov_map, camera)

    tcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)

    tcod.console_set_default_background(panel, tcod.black)
    tcod.console_clear(panel)

    # Print the game messages, one line at a time
    y = 2
    for message in message_log.messages:
        tcod.console_set_default_foreground(panel, message.color)
        tcod.console_print_ex(panel, message_log.x, y, tcod.BKGND_NONE,
                              tcod.LEFT, message.text)
        y += 1

    render_bar(panel, 1, 1, bar_width, 'HP', player._Fighter.hp,
               player._Fighter.max_hp, tcod.light_red, tcod.darker_red)

    tcod.console_set_default_foreground(panel, tcod.light_gray)
    tcod.console_print_ex(
        panel, 1, 0, tcod.BKGND_NONE, tcod.LEFT,
        get_names_under_mouse(mouse, camera, entities, fov_map))

    tcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0, panel_y)

    # 인벤토리
    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
            inventory_title = 'Use which? (Esc to exit)\n'
        else:
            inventory_title = 'Drop which? , or Esc to cancel.\n'
        inventory_menu(con, inventory_title, player._Inventory,
                       screen_width - 2, screen_width, screen_height)
Beispiel #18
0
def render_all(con, panel, entities, player, game_map, fov_recompute,
               root_console, message_log, screen_width, screen_height,
               bar_width, panel_height, panel_y, mouse_coordinates, colors,
               game_state, animations):
    # draw all the tiles in the game map
    root_console.clear()
    if fov_recompute:
        for x, y in game_map:
            wall = not game_map.transparent[x, y]

            if game_map.fov[x, y]:
                if wall:
                    con.draw_char(x,
                                  y,
                                  ' ',
                                  fg=None,
                                  bg=colors.get('light_wall'))
                else:
                    con.draw_char(x,
                                  y,
                                  '.',
                                  fg=colors.get('light_ground_dot'),
                                  bg=colors.get('light_ground'))
                game_map.explored[x][y] = True
            elif game_map.explored[x][y]:
                if wall:
                    con.draw_char(x,
                                  y,
                                  ' ',
                                  fg=None,
                                  bg=colors.get('dark_wall'))
                else:
                    con.draw_char(x,
                                  y,
                                  '.',
                                  fg=colors.get('black'),
                                  bg=colors.get('dark_ground'))
            else:
                con.draw_char(x, y, 176, fg=(30, 30, 30))

    # draw all entities in the list
    entities_in_render_order = sorted(entities,
                                      key=lambda x: x.render_order.value)

    for entity in entities_in_render_order:
        draw_entity(con, entity, game_map)

    panel.clear(fg=colors.get('white'), bg=colors.get('black'))

    # print messages, one line at a time
    y = 1
    for message in message_log.messages:
        panel.draw_str(message_log.x,
                       y,
                       message.text,
                       bg=None,
                       fg=message.color)
        y += 1

    root_console.blit(con, 0, 0, screen_width, screen_height,
                      (player.x - screen_width / 2),
                      (player.y - screen_height / 2))
    render_bar(panel, 1, 1, bar_width, 'HP', player.fighter.hp,
               player.fighter.max_hp, colors.get('light_red'),
               colors.get('darker_red'), colors.get('black'))

    panel.draw_str(1,
                   3,
                   'Dungeon Level: {0}'.format(game_map.dungeon_level),
                   fg=colors.get('white'),
                   bg=None)

    panel.draw_str(
        1, 0, get_names_under_mouse(mouse_coordinates, entities, game_map))
    panel.draw_str(1, 4, 'FPS: {0}'.format(get_fps()))

    root_console.blit(panel, 0, panel_y, screen_width, panel_height, 0, 0)

    # show menus
    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
            inventory_title = 'Select item to use. ESC to cancel.\n'
        else:
            inventory_title = 'Select item to drop. ESC to cancel.\n'
        inventory_menu(con, root_console, inventory_title, player, 50,
                       screen_width, screen_height)
    elif game_state == GameStates.LEVEL_UP:
        level_up_menu(con, root_console, 'Level up!', player, 40, screen_width,
                      screen_height)
    elif game_state == GameStates.CHAR_SCREEN:
        char_screen(root_console, player, 30, 10, screen_width, screen_height)

    if animations:
        for anim in animations:
            result = anim.animate(game_map, mouse_coordinates)
            if result.get('done'):
                animations.remove(anim)
Beispiel #19
0
def render_all(con, panel, entities, player, game_map, fov_map, fov_recompute,
               message_log, screen_width, screen_height, bar_width,
               panel_height, panel_y, mouse, colors, game_state):
    if fov_recompute:
        # Draw all the tiles in the game map
        for y in range(game_map.height):
            for x in range(game_map.width):
                visible = libtcod.map_is_in_fov(fov_map, x, y)
                wall = game_map.tiles[x][y].block_sight

                if visible:
                    if wall:
                        libtcod.console_set_char_background(
                            con, x, y, colors['light_wall'], libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_char_background(
                            con, x, y, colors['light_ground'],
                            libtcod.BKGND_SET)

                    game_map.tiles[x][y].explored = True

                elif game_map.tiles[x][y].explored:
                    if wall:
                        libtcod.console_set_char_background(
                            con, x, y, colors['dark_wall'], libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_char_background(
                            con, x, y, colors['dark_ground'],
                            libtcod.BKGND_SET)

    entities_in_render_order = sorted(entities,
                                      key=lambda x: x.render_order.value)

    # Draw all entities in the list
    for entity in entities_in_render_order:
        draw_entity(con, entity, fov_map, game_map)

    libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)

    libtcod.console_set_default_background(panel, libtcod.black)
    libtcod.console_clear(panel)

    # Print the game messages, one line at a time
    y = 1
    for message in message_log.messages:
        libtcod.console_set_default_foreground(panel, message.color)
        libtcod.console_print_ex(panel, message_log.x, y, libtcod.BKGND_NONE,
                                 libtcod.LEFT, message.text)
        y += 1

    render_bar(panel, 1, 1, bar_width, 'HP', player.fighter.hp,
               player.fighter.max_hp, libtcod.light_red, libtcod.darker_red)
    libtcod.console_print_ex(
        panel, 1, 3, libtcod.BKGND_NONE, libtcod.LEFT,
        'Dungeon level: {0}'.format(game_map.dungeon_level))

    libtcod.console_set_default_foreground(panel, libtcod.light_gray)
    libtcod.console_print_ex(panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT,
                             get_names_under_mouse(mouse, entities, fov_map))

    libtcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0,
                         panel_y)

    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
            inventory_title = 'Press the key next to an item to use it, or Esc to cancel.\n'
        else:
            inventory_title = 'Press the key next to an item to drop it, or Esc to cancel.\n'

        inventory_menu(con, inventory_title, player, 50, screen_width,
                       screen_height)

    elif game_state == GameStates.LEVEL_UP:
        level_up_menu(con, 'Level up! Choose a stat to raise:', player, 40,
                      screen_width, screen_height)

    elif game_state == GameStates.CHARACTER_SCREEN:
        character_screen(player, 30, 10, screen_width, screen_height)

    elif game_state == GameStates.CHARACTER_CREATION:
        character_creation_menu(con, 'Brave peasant! What is your race!:',
                                player, 40, screen_width, screen_height)

    elif game_state == GameStates.GENDER_SELECTION:
        gender_selection_menu(con, 'Brave peasant! What is your gender!:',
                              player, 40, screen_width, screen_height)

    elif game_state == GameStates.JOB_SELECTION:
        job_selection_menu(
            con, 'Congratulations! You have gained a level! Pick a job!:',
            player, 40, screen_width, screen_height)

    elif game_state == GameStates.SKILL_SELECTION:
        job_selection_menu(
            con, 'You have gained a skill! Which button should it go in?:',
            player, 40, screen_width, screen_height)
Beispiel #20
0
def render_all(con, panel, entities, player, game_map, fov_map, fov_recompute,
               message_log, screen_width, screen_height, bar_width,
               panel_height, panel_y, mouse, colors, game_state):
    if fov_recompute:
        # Draw all the tiles in the game map
        for y in range(game_map.height):
            for x in range(game_map.width):
                visible = libtcod.map_is_in_fov(fov_map, x, y)
                wall = game_map.tiles[x][y].block_sight

                if visible:
                    if wall:
                        libtcod.console_set_char_background(
                            con, x, y, colors.get('light_wall'),
                            libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_char_background(
                            con, x, y, colors.get('light_ground'),
                            libtcod.BKGND_SET)

                    game_map.tiles[x][y].explored = True
                elif game_map.tiles[x][y].explored:
                    if wall:
                        libtcod.console_set_char_background(
                            con, x, y, colors.get('dark_wall'),
                            libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_char_background(
                            con, x, y, colors.get('dark_ground'),
                            libtcod.BKGND_SET)

    entities_in_render_order = sorted(entities,
                                      key=lambda x: x.render_order.value)

    # Draw all entities in the list
    for entity in entities_in_render_order:
        draw_entity(con, entity, fov_map, game_map)

    libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)

    libtcod.console_set_default_background(panel, libtcod.black)
    libtcod.console_clear(panel)

    # Print the game messages, one line at a time
    y = 1
    for message in message_log.messages:
        libtcod.console_set_default_foreground(panel, message.color)
        libtcod.console_print_ex(panel, message_log.x, y, libtcod.BKGND_NONE,
                                 libtcod.LEFT, message.text)
        y += 1

    render_bar(panel, 1, 1, bar_width, 'HP', player.fighter.hp,
               player.fighter.max_hp, libtcod.light_red, libtcod.darker_red)
    render_bar(panel, 1, 2, bar_width, 'Mana', player.fighter.mana,
               player.fighter.max_mana, libtcod.light_blue,
               libtcod.darker_blue)
    libtcod.console_print_ex(
        panel, 1, 3, libtcod.BKGND_NONE, libtcod.LEFT,
        'Dungeon level: {0}'.format(game_map.dungeon_level))
    libtcod.console_print_ex(panel, 1, 4, libtcod.BKGND_NONE, libtcod.LEFT,
                             'Nutrition: {0}'.format(player.fighter.nutrition))
    libtcod.console_print_ex(panel, 1, 5, libtcod.BKGND_NONE, libtcod.LEFT,
                             'AC: {0}'.format(player.fighter.ac))

    libtcod.console_set_default_foreground(panel, libtcod.light_gray)
    libtcod.console_print_ex(panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT,
                             get_names_under_mouse(mouse, entities, fov_map))

    libtcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0,
                         panel_y)

    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
            inventory_title = 'Press the key next to an item to use it, or Esc to cancel.\n'
        else:
            inventory_title = 'Press the key next to an item to drop it, or Esc to cancel.\n'

        inventory_menu(con, inventory_title, player, 50, screen_width,
                       screen_height)

    elif game_state == GameStates.LEVEL_UP:
        level_up_menu(con, 'Level up! Choose a stat to raise:', player, 40,
                      screen_width, screen_height)

    elif game_state == GameStates.CHARACTER_SCREEN:
        character_screen(player, 30, 11, screen_width, screen_height)

    elif game_state == GameStates.RACE_SELECTION:
        race_select_menu(con, 'What is your race?', player, 40, screen_width,
                         screen_height)

    elif game_state == GameStates.SKILL_SELECTION:
        skill_menu(con, 'What skill would you like to use?', player, 40,
                   screen_width, screen_height)

    elif game_state == GameStates.CLASS_SELECTION:
        job_selection_menu(con, 'What class do you want to level in?', player,
                           40, screen_width, screen_height)

    elif game_state == GameStates.JOB_MENU:
        job_screen(player, 30, 10, screen_width, screen_height)
Beispiel #21
0
def render_all(con, panel, entities, player, game_map, fov_map, fov_recompute,
               message_log, screen_width, screen_height, bar_width,
               panel_height, panel_y, mouse, colors, game_state, graphics):
    """
    Affiche les pièces, les entites, les menus, et tous les éléments du jeu

    Parametres:
    ----------
    con : tcod.console

    panel : tcod.console

    entities : list

    player : Entity

    game_map : GameMap

    fov_map : tcod.map

    fov_recompute : bool

    message_log : MessageLog

    screen_width : int

    screen_height : int

    bar_width : int

    panel_heidght : int

    panel_y : int

    mouse : tcod.mouse

    colors : tcod.colors
        Désormais non utilisé

    game_state : int

    graphics : dict


    Renvoi:
    -------
    Aucun

    """
    if fov_recompute:
        for y in range(game_map.height):
            for x in range(game_map.width):
                visible = libtcod.map_is_in_fov(fov_map, x, y)
                wall = game_map.tiles[x][y].block_sight
                if visible:
                    if wall:
                        libtcod.console_put_char_ex(con, x, y,
                                                    graphics.get('wall'),
                                                    libtcod.white,
                                                    libtcod.black)
                    else:
                        libtcod.console_put_char_ex(con, x, y,
                                                    graphics.get('floor'),
                                                    libtcod.white,
                                                    libtcod.black)
                    game_map.tiles[x][y].explored = True
                elif game_map.tiles[x][y].explored:
                    if wall:
                        libtcod.console_put_char_ex(con, x, y,
                                                    graphics.get('wall'),
                                                    libtcod.light_grey,
                                                    libtcod.black)
                    else:
                        libtcod.console_put_char_ex(con, x, y,
                                                    graphics.get('floor'),
                                                    libtcod.light_grey,
                                                    libtcod.black)
    entities_in_render_order = sorted(entities,
                                      key=lambda x: x.render_order.value)

    for entity in entities_in_render_order:
        draw_entity(con, entity, fov_map, game_map)
        if entity.ai:
            if entity.ai.ai_name == 'Boss':
                if entity.ai.aoeing:
                    if entity.ai.turn % 10 == 0:
                        color = libtcod.lightest_red
                    elif entity.ai.turn % 10 == 1:
                        color = libtcod.lighter_red
                    elif entity.ai.turn % 10 == 2:
                        color = libtcod.light_red
                    elif entity.ai.turn % 10 == 3:
                        color = libtcod.red
                    radius = entity.ai.radius
                    for x in range(entity.x - radius, entity.x + radius + 1):
                        for y in range(entity.y - radius,
                                       entity.y + radius + 1):
                            if ((x - entity.x)**2 +
                                (y - entity.y)**2)**0.5 <= radius:
                                libtcod.console_set_char_foreground(
                                    con, x, y, color)

    libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)
    libtcod.console_set_default_background(panel, libtcod.black)
    libtcod.console_clear(panel)

    y = 1
    for message in message_log.messages:
        libtcod.console_set_default_foreground(panel, message.color)
        libtcod.console_print_ex(panel, message_log.x, y, libtcod.BKGND_NONE,
                                 libtcod.LEFT, message.text)
        y += 1

    render_bar(panel, 1, 1, bar_width, 'HP', player.fighter.hp,
               player.fighter.max_hp, libtcod.light_red, libtcod.darker_red)
    libtcod.console_print_ex(
        panel, 1, 2, libtcod.BKGND_NONE, libtcod.LEFT,
        'Salle : {0} - LVL : {1}'.format(game_map.dungeon_level,
                                         player.level.current_level))
    boss_bar = False
    for entity in entities:
        if entity.name == 'Boss':
            boss_bar = True
            boss = entity.fighter
    if boss_bar:
        render_bar(panel, 1, 3, bar_width, 'Boss HP', boss.hp, boss.max_hp,
                   libtcod.orange, libtcod.darker_orange)
    else:
        render_bar(panel, 1, 3, bar_width, 'XP', player.level.current_xp,
                   player.level.experience_to_next_level, libtcod.light_purple,
                   libtcod.darker_purple)
    libtcod.console_print_ex(
        panel, 1, 4, libtcod.BKGND_NONE, libtcod.LEFT,
        'ATQ : {0} - DEF : {1}'.format(player.fighter.power,
                                       player.fighter.defense))

    libtcod.console_set_default_foreground(panel, libtcod.light_gray)
    libtcod.console_print_ex(panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT,
                             get_names_under_mouse(mouse, entities, fov_map))
    libtcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0,
                         panel_y)
    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
            inventory_title = 'Echap pour quitter, A/B/C... pour utiliser.\n'
        else:
            inventory_title = 'Echap pour quitter, A/B/C... pour lacher\n'
        inventory_menu(con, inventory_title, player, 50, screen_width,
                       screen_height)
    elif game_state == GameStates.LEVEL_UP:
        level_up_menu(con, 'Level up, choisis une amelioration :', player, 40,
                      screen_width, screen_height)
    elif game_state == GameStates.CHARACTER_SCREEN:
        character_screen(player, 30, 10, screen_width, screen_height)
Beispiel #22
0
def render_all(con, panel, entities, player, game_map, fov_map, fov_recompute,
               screen_width, screen_height, message_log, bar_width,
               panel_height, panel_y, mouse, colors, game_state):
    """Renders the map according to the FOV map, then draws all passed entities"""
    if fov_recompute:
        for y in range(game_map.height):
            for x in range(game_map.width):
                visible = libtcod.map_is_in_fov(fov_map, x, y)
                wall = game_map.tiles[x][y].block_sight

                if visible:
                    if wall:
                        libtcod.console_set_char_background(
                            con, x, y, colors.get('light_wall'),
                            libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_char_background(
                            con, x, y, colors.get('light_ground'),
                            libtcod.BKGND_SET)

                    game_map.tiles[x][y].explored = True

                elif game_map.tiles[x][
                        y].explored:  # Draws the map for the player (doesn't keep entities lit)
                    if wall:
                        libtcod.console_set_char_background(
                            con, x, y, colors.get('dark_wall'),
                            libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_char_background(
                            con, x, y, colors.get('dark_ground'),
                            libtcod.BKGND_SET)

    # Draw all entity objects in the 'entities' list, in render order
    entities_in_render_order = sorted(entities,
                                      key=lambda x: x.render_order.value)
    for entity in entities_in_render_order:
        draw_entity(con, entity, fov_map, game_map)

    libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)

    libtcod.console_set_default_background(panel, libtcod.black)
    libtcod.console_clear(panel)

    # Print the game messages, line by line
    y = 1
    for message in message_log.messages:
        libtcod.console_set_default_foreground(panel, message.color)
        libtcod.console_print_ex(panel, message_log.x, y, libtcod.BKGND_NONE,
                                 libtcod.LEFT, message.text)
        y += 1

    # Health Bar and Dungeon Level
    render_bar(panel, 1, 1, bar_width, 'HP', player.fighter.hp,
               player.fighter.max_hp, libtcod.light_red, libtcod.darker_red)
    libtcod.console_print_ex(
        panel, 1, 3, libtcod.BKGND_NONE, libtcod.LEFT,
        'Dungeon level: {}'.format(game_map.dungeon_level))

    # Information about an entity under the mouse cursor
    libtcod.console_set_default_foreground(panel, libtcod.light_gray)
    libtcod.console_print_ex(panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT,
                             get_names_under_mouse(mouse, entities, fov_map))

    libtcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0,
                         panel_y)

    # Inventory Menu
    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
            inventory_title = "Press the key next to an item to use it, or ESC to close.\n"
        else:
            inventory_title = "Press the key next to an item to drop it, or ESC to close.\n"

        inventory_menu(con, inventory_title, player, 50, screen_width,
                       screen_height)

    # Level Up Menu
    elif game_state == GameStates.LEVEL_UP:
        level_up_menu(con, "Level up! Choose a stat to raise:", player, 40,
                      screen_width, screen_height)

    # Character Screen
    elif game_state == GameStates.CHARACTER_SCREEN:
        character_screen(player, 30, 10, screen_width, screen_height)
def render_all(con, panel, entities, player, game_map, fov_map, fov_recompute,
               message_log, screen_width, screen_height, bar_width,
               panel_height, panel_y, mouse, colors, game_state):
    if fov_recompute:
        for y in range(game_map.height):
            for x in range(game_map.width):
                visible = fov_map.fov[y][x]
                wall = game_map.tiles[x][y].block_sight
                if visible:
                    if wall:
                        libtcod.console_set_char_background(
                            con, x, y, colors.get("light_wall"),
                            libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_char_background(
                            con, x, y, colors.get("light_ground"),
                            libtcod.BKGND_SET)
                    game_map.tiles[x][y].explored = True
                elif game_map.tiles[x][y].explored:
                    if wall:
                        libtcod.console_set_char_background(
                            con, x, y, colors.get("dark_wall"),
                            libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_char_background(
                            con, x, y, colors.get("dark_ground"),
                            libtcod.BKGND_SET)

    entities_in_render_order = sorted(entities,
                                      key=lambda x: x.render_order.value)

    for entity in entities_in_render_order:
        if fov_map.fov[entity.y][entity.x] or (
                entity.stairs and game_map.tiles[entity.x][entity.y].explored):
            draw_entity(con, entity)

    libtcod.console_set_default_background(panel, libtcod.black)
    libtcod.console_clear(panel)

    render_bar(panel, 1, 1, bar_width, "HP", player.fighter.hp,
               player.fighter.max_hp, libtcod.light_red, libtcod.darker_red)

    libtcod.console_print_ex(
        panel, 1, 3, libtcod.BKGND_NONE, libtcod.LEFT,
        "Dungeon level: {}".format(game_map.dungeon_level))

    libtcod.console_set_default_foreground(panel, libtcod.light_gray)
    libtcod.console_print_ex(panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT,
                             get_names_under_mouse(mouse, entities, fov_map))

    y = 1
    for message in message_log.messages:
        libtcod.console_set_default_foreground(panel, message.color)
        libtcod.console_print_ex(panel, message_log.x, y, libtcod.BKGND_NONE,
                                 libtcod.LEFT, message.text)
        y += 1

    libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)
    libtcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0,
                         panel_y)

    inventory_title = None
    if game_state == GameStates.SHOW_INVENTORY:
        inventory_title = "Press the key next to an item to use it, or Esc to cancel.\n"
    elif game_state == GameStates.DROP_INVENTORY:
        inventory_title = "Press the key next to an item to drop it, or Esc to cancel.\n"

    if inventory_title != None:
        inventory_menu(con, inventory_title, player, player.inventory, 50,
                       screen_width, screen_height)

    if game_state == GameStates.LEVEL_UP:
        level_up_menu(con, "Level up! Choose a stat to raise:", player, 40,
                      screen_width, screen_height)

    if game_state == GameStates.CHARACTER_SCREEN:
        character_screen(player, 30, 10, screen_width, screen_height)
def render_all(con, panel, entities, player, game_map, fov_map, fov_recompute, message_log, screen_width, screen_height,
               bar_width, panel_height, panel_y, mouse, colors,game_state):
    if fov_recompute:
    # Draw all the tiles in the game map
        for y in range(game_map.height):
            for x in range(game_map.width):
                visible = libtcod.map_is_in_fov(fov_map, x, y)
                wall = game_map.tiles[x][y].block_sight

                if visible:
                    if wall:
                        #libtcod.console_set_char_background(con, x, y, colors.get('light_wall'), libtcod.BKGND_SET)
                        libtcod.console_set_default_foreground(con, libtcod.white)
                        libtcod.console_put_char(con, x, y, const.Grass_Light_tile, libtcod.BKGND_NONE)
                    else:
                        #libtcod.console_set_char_background(con, x, y, colors.get('light_ground'), libtcod.BKGND_SET)
                        libtcod.console_set_default_foreground(con,libtcod.white)
                        libtcod.console_put_char(con,x,y, const.Court_tile , libtcod.BKGND_NONE)

                    game_map.tiles[x][y].explored = True
                elif game_map.tiles[x][y].explored:
                    if wall:
                        #libtcod.console_set_char_background(con, x, y, colors.get('dark_wall'), libtcod.BKGND_SET)
                        libtcod.console_set_default_foreground(con, libtcod.white)
                        libtcod.console_put_char(con, x, y, const.Grass_Dark_tile , libtcod.BKGND_NONE)
                    else:
                        #libtcod.console_set_char_background(con, x, y, colors.get('dark_ground'), libtcod.BKGND_SET)
                        libtcod.console_set_default_foreground(con, libtcod.white)
                        libtcod.console_put_char(con, x, y, const.Court_tile , libtcod.BKGND_NONE)

    entities_in_render_order = sorted(entities, key=lambda x: x.render_order.value)

    # Draw all entities in the list
    for entity in entities_in_render_order:
        draw_entity(con, entity, fov_map,game_map)

    libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)

    libtcod.console_set_default_background(panel, libtcod.black)
    libtcod.console_clear(panel)

    # Print the game messages, one line at a time
    y = 1
    for message in message_log.messages:
        libtcod.console_set_default_foreground(panel, message.color)
        libtcod.console_print_ex(panel, message_log.x, y, libtcod.BKGND_NONE, libtcod.LEFT, message.text)
        y += 1

    render_bar(panel, 1, 1, bar_width, 'HP', player.fighter.hp, player.fighter.max_hp,
               libtcod.light_red, libtcod.darker_red)

    libtcod.console_print_ex(panel, 1, 3, libtcod.BKGND_NONE, libtcod.LEFT,
                             'Dungeon level: {0}'.format(game_map.dungeon_level))

    libtcod.console_set_default_foreground(panel, libtcod.light_gray)
    libtcod.console_print_ex(panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT,
                             get_names_under_mouse(mouse, entities, fov_map))

    libtcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0, panel_y)

    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
            inventory_title = 'Press the key next to an item to use it, or Esc to cancel.\n'
        else:
            inventory_title = 'Press the key next to an item to drop it, or Esc to cancel.\n'

        inventory_menu(con, inventory_title, player, 50, screen_width, screen_height)

    elif game_state == GameStates.LEVEL_UP:
        level_up_menu(con, 'Level up! Choose a stat to raise:', player, 40, screen_width, screen_height)
    elif game_state == GameStates.EVOLVE:
        evolve_menu(con,'Your player is evolved!',player,40,screen_width,screen_height)
    elif game_state == GameStates.CHARACTER_SCREEN:
        character_screen(player, 30, 10, screen_width, screen_height)
    elif game_state == GameStates.COMMAND_MENU:
        commandMenu(screen_width, screen_height, screen_width, screen_height)
    elif game_state == GameStates.WIN_MENU:
        WinMenu(con, screen_width, screen_height)
    elif game_state == GameStates.PLAYER_DEAD:
        DiedMenu(con, screen_width, screen_height)
def render_all(con, panel, entities, player, game_map, fov_map, fov_recompute,
               message_log, screen_width, screen_height, bar_width,
               panel_height, panel_y, mouse, colors, game_state):
    wall_tile = 256
    floor_tile = 257
    player_tile = 258
    orc_tile = 259
    troll_tile = 260
    scroll_tile = 261
    healingpotion_tile = 262
    sword_tile = 263
    shield_tile = 264
    stairsdown_tile = 265
    dagger_tile = 266

    if fov_recompute:
        # Draw all the tiles in the game map
        for y in range(game_map.height):
            for x in range(game_map.width):
                visible = libtcod.map_is_in_fov(fov_map, x, y)
                wall = game_map.tiles[x][y].block_sight

                if visible:
                    if wall:
                        libtcod.console_put_char_ex(con, x, y, wall_tile,
                                                    libtcod.white,
                                                    libtcod.black)
                    else:
                        libtcod.console_put_char_ex(con, x, y, floor_tile,
                                                    libtcod.white,
                                                    libtcod.black)

                    game_map.tiles[x][y].explored = True
                elif game_map.tiles[x][y].explored:
                    if wall:
                        libtcod.console_put_char_ex(con, x, y, wall_tile,
                                                    libtcod.grey,
                                                    libtcod.black)
                    else:
                        libtcod.console_put_char_ex(con, x, y, floor_tile,
                                                    libtcod.grey,
                                                    libtcod.black)

    entities_in_render_order = sorted(entities,
                                      key=lambda x: x.render_order.value)

    # Draw all entities in the list
    for entity in entities_in_render_order:
        draw_entity(con, entity, fov_map, game_map)

    libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)

    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
            inventory_title = 'Press the key next to an item to use it, or Esc to cancel.\n'
        else:
            inventory_title = 'Press the key next to an item to drop it, or Esc to cancel.\n'

        inventory_menu(con, inventory_title, player, 50, screen_width,
                       screen_height)

    elif game_state == GameStates.LEVEL_UP:
        level_up_menu(con, 'Level up! Choose a stat to raise:', player, 40,
                      screen_width, screen_height)

    elif game_state == GameStates.CHARACTER_SCREEN:
        character_screen(player, 30, 10, screen_width, screen_height)

    libtcod.console_set_default_background(panel, libtcod.black)
    libtcod.console_clear(panel)

    # Print the game messages, one line at a time
    y = 1
    for message in message_log.messages:
        libtcod.console_set_default_foreground(panel, message.color)
        libtcod.console_print_ex(panel, message_log.x, y, libtcod.BKGND_NONE,
                                 libtcod.LEFT, message.text)
        y += 1

    render_bar(panel, 1, 1, bar_width, 'HP', player.fighter.hp,
               player.fighter.max_hp, libtcod.light_red, libtcod.darker_red)
    libtcod.console_print_ex(
        panel, 1, 3, libtcod.BKGND_NONE, libtcod.LEFT,
        'Dungeon level: {0}'.format(game_map.dungeon_level))

    libtcod.console_set_default_foreground(panel, libtcod.light_gray)
    libtcod.console_print_ex(panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT,
                             get_names_under_mouse(mouse, entities, fov_map))

    libtcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0,
                         panel_y)
Beispiel #26
0
def render_all(con, panel, entities, player, game_map, fov_map, fov_recompute,
               message_log, screen_width, screen_height, bar_width,
               panel_height, panel_y, mouse, colors, game_state, camera):
    # Draw the tiles in the given map
    if fov_recompute:
        libtcod.console_clear(
            con
        )  # This was required to get screen scrolling working. There may be a more efficient way to update the screen but I can't think of one.
        for y in range(game_map.height):
            for x in range(game_map.width):
                visible = libtcod.map_is_in_fov(fov_map, x, y)
                wall = game_map.tiles[x][y].block_sight
                x_in_camera, y_in_camera = camera.apply(x, y)

                if visible:
                    if wall:
                        libtcod.console_set_char_background(
                            con, x_in_camera, y_in_camera,
                            colors.get('light_wall'), libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_char_background(
                            con, x_in_camera, y_in_camera,
                            colors.get('light_ground'), libtcod.BKGND_SET)

                    game_map.tiles[x][y].explored = True
                elif game_map.tiles[x][y].explored:
                    if wall:
                        libtcod.console_set_char_background(
                            con, x_in_camera, y_in_camera,
                            colors.get('dark_wall'), libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_char_background(
                            con, x_in_camera, y_in_camera,
                            colors.get('dark_ground'), libtcod.BKGND_SET)

    entities_in_render_order = sorted(entities,
                                      key=lambda x: x.render_order.value)

    for entity in entities_in_render_order:
        draw_entity(con, entity, fov_map, game_map, camera)

    libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)

    libtcod.console_set_default_background(panel, libtcod.black)
    libtcod.console_clear(panel)

    y = 1
    for message in message_log.visible:
        libtcod.console_set_default_foreground(panel, message.color)
        libtcod.console_print_ex(panel, message_log.x, y, libtcod.BKGND_NONE,
                                 libtcod.LEFT, message.text)
        y += 1

    render_bar(panel, 1, 1, bar_width, 'HP', player.fighter.hp,
               player.fighter.max_hp, libtcod.light_red, libtcod.darker_red)
    libtcod.console_print_ex(
        panel, 1, 3, libtcod.BKGND_NONE, libtcod.LEFT,
        'Dungeon level: {0}'.format(game_map.dungeon_level))

    libtcod.console_set_default_foreground(panel, libtcod.light_gray)
    libtcod.console_print_ex(panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT,
                             get_names_under_mouse(mouse, entities, fov_map))

    libtcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0,
                         panel_y)

    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
            inventory_title = 'Press the key next to an item to use it. Press Esc to cancel.\n'
        else:
            inventory_title = 'Press the key next to an item to drop it. Press Esc to cancel.\n'

        inventory_menu(con, inventory_title, player, 50, screen_width,
                       screen_height)

    elif game_state == GameStates.LEVEL_UP:
        level_up_menu(con, 'Level up! Choose a stat to increase:', player, 40,
                      screen_width, screen_height)

    elif game_state == GameStates.CHARACTER_SCREEN:
        character_screen(
            player, 30, 10, screen_width,
            screen_height)  # TODO: More constants all over the place here

    elif game_state == GameStates.FULLSCREEN_CONSOLE:
        window = libtcod.console_new(screen_width, screen_height)

        z = 1
        for message in message_log.fullscreen_visible:
            libtcod.console_set_default_foreground(window, message.color)
            libtcod.console_print_ex(window, 0, z, libtcod.BKGND_NONE,
                                     libtcod.LEFT, message.text)
            z += 1

        libtcod.console_blit(window, 0, 0, screen_width, screen_height, 0, 0,
                             0)
def render_all(con, panel, entities, player, game_map, fov_map, fov_recompute,
               message_log, screen_width, screen_height, bar_width,
               panel_height, panel_y, mouse, colors, game_state, camera):
    if fov_recompute:
        libtcod.console_clear(con)
        # Draw all the tiles in the game map
        for y in range(game_map.height):
            for x in range(game_map.width):
                #camera code
                x_in_camera, y_in_camera = x + camera.x, y + camera.y  #camera.apply(x, y)

                visible = libtcod.map_is_in_fov(fov_map, x, y)
                wall = game_map.tiles[x][y].block_sight

                #시야에 따른 벽과 바닥 색깔/캐릭터 렌더링
                if visible:
                    game_map.tiles[x][y].explored = True
                    if wall:  #피 묻었는지 안 묻었는지 체크
                        if game_map.tiles[x][y].bloodied:
                            #libtcod.console_put_char_ex(con, x, y,'▒',libtcod.red, colors.get('dark_wall'))
                            libtcod.console_put_char_ex(
                                con, x_in_camera, y_in_camera, '▒',
                                libtcod.red, colors.get('dark_wall'))

                        else:
                            libtcod.console_put_char_ex(
                                con, x_in_camera, y_in_camera, '▒',
                                libtcod.white, colors.get('dark_wall'))

                    else:
                        if game_map.tiles[x][y].bloodied:
                            libtcod.console_put_char_ex(
                                con, x_in_camera, y_in_camera, '.',
                                libtcod.red, colors.get('light_ground'))
                        else:
                            libtcod.console_put_char_ex(
                                con, x_in_camera, y_in_camera, '.',
                                libtcod.white, colors.get('light_ground'))
                            #libtcod.console_set_char_background(con, x, y, colors.get('light_ground'), libtcod.BKGND_SET)

                elif game_map.tiles[x][y].explored:
                    if wall:
                        libtcod.console_put_char_ex(con, x_in_camera,
                                                    y_in_camera, '▒',
                                                    libtcod.dark_grey,
                                                    colors.get('dark_ground'))
                        #libtcod.console_put_char_ex(con, x, y, 176, colors.get('light_wall'), colors.get('dark_wall'))
                    else:
                        libtcod.console_put_char_ex(con, x_in_camera,
                                                    y_in_camera, ' ',
                                                    libtcod.dark_grey,
                                                    colors.get('dark_ground'))
                        #libtcod.console_set_char_background(con, x, y, colors.get('dark_ground'), libtcod.BKGND_SET)
                else:
                    libtcod.console_set_char_background(
                        con, x_in_camera, y_in_camera, libtcod.Color(0, 0, 0),
                        libtcod.BKGND_SET)
    entities_in_render_order = sorted(entities,
                                      key=lambda x: x.render_order.value)
    #game_map.tiles[x][y].explored |= self.fov

    # Draw all entities in the list
    for entity in entities_in_render_order:
        draw_entity(con, entity, fov_map, game_map, camera)

    #draw hp?
    libtcod.console_set_default_foreground(panel, libtcod.white)
    #libtcod.console_set_default_background(con, libtcod.Color(0, 63, 0))
    libtcod.console_print_ex(
        panel, 1, screen_height - 2, libtcod.BKGND_NONE, libtcod.LEFT,
        'HP: {0:02}/{1:02}'.format(player.fighter.hp, player.fighter.max_hp))

    libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)

    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
            inventory_title = 'Press the key next to an item to use it, or Esc to cancel.\n'
        else:
            inventory_title = 'Press the key next to an item to drop it, or Esc to cancel.\n'

        inventory_menu(con, inventory_title, player, 50, screen_width,
                       screen_height)

    elif game_state == GameStates.LEVEL_UP:
        level_up_menu(con, 'Level up! Choose a stat to raise:', player, 40,
                      screen_width, screen_height)

    elif game_state == GameStates.CHARACTER_SCREEN:
        character_screen(player, 30, 10, screen_width, screen_height)

    #libtcod.console_set_default_background(panel, libtcod.black)
    libtcod.console_set_default_background(panel, libtcod.Color(0, 20, 30))
    libtcod.console_clear(panel)

    # Print the game messages, one line at a time
    y = 1
    for message in message_log.messages:
        libtcod.console_set_default_foreground(panel, message.color)
        libtcod.console_print_ex(panel, message_log.x, y, libtcod.BKGND_NONE,
                                 libtcod.LEFT, message.text)
        y += 1

    render_bar(panel, 1, 1, bar_width, 'HP', player.fighter.hp,
               player.fighter.max_hp, libtcod.light_red, libtcod.darker_red)

    libtcod.console_print_ex(
        panel, 1, 3, libtcod.BKGND_NONE, libtcod.LEFT,
        'Dungeon level: {0}'.format(game_map.dungeon_level))

    #libtcod.console_clear(animation_con)

    libtcod.console_set_default_foreground(panel, libtcod.light_gray)

    libtcod.console_print_ex(
        panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT,
        get_names_under_mouse(con, mouse, camera, entities, fov_map))
    #libtcod.console_print_rect(con, mouse.cx, mouse.cy,20,1,get_names_under_mouse(con, mouse, camera, entities, fov_map))

    libtcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0,
                         panel_y)
Beispiel #28
0
def render_all(con, panel, game_map, entities, player, fov_map, fov_recompute,
               message_log, screen_width, screen_height, bar_width,
               panel_height, panel_y, mouse, tile_data, game_state):

    entities_in_render_order = sorted(entities,
                                      key=lambda x: x.render_order.value)
    for entity in entities_in_render_order:
        draw_entity(con, entity, fov_map, game_map)

    if fov_recompute:
        stairs_x, stairs_y = stairs_location(entities)

        for y in range(game_map.height):
            for x in range(game_map.width):

                visible = lc.map_is_in_fov(fov_map, x, y)

                if visible:
                    lc.console_set_char_background(
                        con, x, y,
                        tile_data.get(game_map.tiles[x][y].terrain)['light'],
                        lc.BKGND_SET)
                    if not (y == stairs_y and x == stairs_x):
                        lc.console_set_char_foreground(
                            con, x, y,
                            tile_data.get(
                                game_map.tiles[x][y].terrain)['dark'])
                        lc.console_set_char(con, x, y,
                                            chr(game_map.tiles[x][y].texture))
                    game_map.tiles[x][y].explored = True
                elif game_map.tiles[x][y].explored:
                    # lc.console_put_char(con,x,y,chr(game_map.tiles[x][y].texture),lc.BKGND_NONE)

                    lc.console_set_char_background(
                        con, x, y,
                        tile_data.get(game_map.tiles[x][y].terrain)['dark'],
                        lc.BKGND_SET)
                    if not (y == stairs_y and x == stairs_x):
                        lc.console_set_char_foreground(con, x, y, lc.black)
                        lc.console_set_char(con, x, y,
                                            chr(game_map.tiles[x][y].texture))

    lc.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)

    lc.console_set_default_background(panel, lc.black)
    lc.console_clear(panel)

    y = 1
    for message in message_log.messages:
        lc.console_set_default_foreground(panel, message.colour)
        lc.console_print_ex(panel, message_log.x, y, lc.BKGND_NONE, lc.LEFT,
                            message.text)
        y += 1

    render_bar(panel, 1, 1, bar_width, 'HP', player.fighter.health,
               player.fighter.max_health, lc.red, lc.darker_red)
    lc.console_print_ex(panel, 1, 3, lc.BKGND_NONE, lc.LEFT,
                        'Dungeon Level: {0}'.format(game_map.floor))

    lc.console_set_default_background(panel, lc.light_gray)
    lc.console_print_ex(panel, 1, 0, lc.BKGND_NONE, lc.LEFT,
                        get_names_under_mouse(mouse, entities, fov_map))

    lc.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0, panel_y)

    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
            inventory_title = 'Press the key next to an item to use it or Esc to cancel.\n'
        else:
            inventory_title = 'Press the key next to an item to drop it or Esc to cancel. \n'

        inventory_menu(con, inventory_title, player, 50, screen_width,
                       screen_height)
    elif game_state == GameStates.LEVEL_UP:
        level_up_menu(con, 'Level up! Choose a stat to raise:', player, 40,
                      screen_width, screen_height)
    elif game_state == GameStates.CHARACTER_SCREEN:
        character_screen(player, 30, 10, screen_width, screen_height)
def render_all(con, panel, entities, player, game_map, fov_map, fov_recompute,
               message_log, screen_width, screen_height, bar_width,
               panel_height, panel_y, mouse, colors, kill_count, game_state):
    if fov_recompute:
        for y in range(game_map.height):
            for x in range(game_map.width):
                visible = libtcod.map_is_in_fov(fov_map, x, y)
                wall = game_map.tiles[x][y].block_sight

                if visible:
                    if wall:
                        libtcod.console_set_char_background(
                            con, x, y, colors.get('light_wall'),
                            libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_char_background(
                            con, x, y, colors.get('light_ground'),
                            libtcod.BKGND_SET)

                    game_map.tiles[x][y].explored = True
                elif game_map.tiles[x][y].explored:
                    if wall:
                        libtcod.console_set_char_background(
                            con, x, y, colors.get('dark_wall'),
                            libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_char_background(
                            con, x, y, colors.get('dark_ground'),
                            libtcod.BKGND_SET)

    entities_in_render_order = sorted(entities,
                                      key=lambda x: x.render_order.value)

    for entity in entities_in_render_order:
        draw_entity(con, entity, fov_map, game_map)

    libtcod.console_set_default_foreground(con, libtcod.white)
    libtcod.console_print_ex(
        con, 1, screen_height - 2, libtcod.BKGND_NONE, libtcod.LEFT,
        "HP: {0:02}/{1:02}".format(player.fighter.hp, player.fighter.max_hp))
    ''' Danny code to center player and have window scroll
    r = 20
    libtcod.console_blit(con, player.x - r, player.y - r, 2*r+1, 2*r+1, 0, int(screen_width/2) - r, int(screen_height/2) - r)
    '''
    libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)

    libtcod.console_set_default_background(panel, libtcod.black)
    libtcod.console_clear(panel)

    y = 1
    for message in message_log.messages:
        libtcod.console_set_default_foreground(panel, message.color)
        libtcod.console_print_ex(panel, message_log.x, y, libtcod.BKGND_NONE,
                                 libtcod.LEFT, message.text)
        y += 1

    render_bar(panel, 1, 1, bar_width, "HP", player.fighter.hp,
               player.fighter.max_hp, libtcod.light_red, libtcod.darker_red)

    render_bar(panel, 1, 2, bar_width, "EXP", player.level.current_xp,
               player.level.experience_to_next_level, libtcod.light_blue,
               libtcod.darker_blue)

    libtcod.console_print_ex(panel, 1, 4, libtcod.BKGND_NONE, libtcod.LEFT,
                             "Gold: {0}".format(player.fighter.gold))

    if player.inventory.search("Health Talisman") is not None:
        render_bar(panel, 1, 3, bar_width, "Talisman HP",
                   player.fighter.talismanhp, player.fighter.max_hp,
                   libtcod.light_purple, libtcod.darker_purple)

    libtcod.console_print_ex(
        panel, 1, 5, libtcod.BKGND_NONE, libtcod.LEFT,
        "Dungeon Level: {0}".format(game_map.dungeon_level))

    libtcod.console_set_default_foreground(panel, libtcod.light_gray)
    libtcod.console_print_ex(panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT,
                             get_names_under_mouse(mouse, entities, fov_map))

    libtcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0,
                         panel_y)

    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
            inventory_title = "Press the key next to an item to use it, or ESC to cancel.\n"
        elif game_state == GameStates.DROP_INVENTORY:
            inventory_title = "Press the key next to an item to drop it, or ESC to cancel.\n"

        inventory_menu(con, inventory_title, player, 50, screen_width,
                       screen_height)

    elif game_state in (GameStates.SHOW_EQUIPMENT_INVENTORY,
                        GameStates.DROP_EQUIPMENT):
        if game_state == GameStates.SHOW_EQUIPMENT_INVENTORY:
            inventory_title = "Press the key next to an item to equip it, or ESC to cancel.\n"
        else:
            inventory_title = "Press the key next to the equipment to drop it, or ESC to cancel.\n"

        equipment_inventory_menu(con, inventory_title, player, 50,
                                 screen_width, screen_height)

    elif game_state == GameStates.LEVEL_UP:
        level_up_menu(con, "Level up! Choose a stat to raise:\n", player, 46,
                      screen_width, screen_height)

    elif game_state == GameStates.CHARACTER_SCREEN:
        character_screen(player, 30, 10, screen_width, screen_height,
                         kill_count)

    elif game_state == GameStates.SHOW_BAG:
        bag_title = "Press the key next to the option to open the bag.\n"

        bag_menu(con, bag_title, player, 50, screen_width, screen_height)

    elif game_state == GameStates.HELP_MENU:
        help_menu(player, 30, 10, screen_width, screen_height)

    elif game_state == GameStates.QUIT_MENU:
        quit_title = "ARE YOU SURE YOU WANT\n  TO QUIT THE GAME?\n"

        quit_menu(con, quit_title, player, 21, screen_width, screen_height)

    elif game_state == GameStates.DROP_MENU:
        drop_title = "Which inventory would you like to drop items from?"

        drop_menu(con, drop_title, player, 50, screen_width, screen_height)

    elif game_state == GameStates.SELL_MENU:
        shop_title = "Welcome to the Shop!\nWhat would you like to sell?\n"

        sell_menu(con, shop_title, player, 50, screen_width, screen_height)

    elif game_state == GameStates.BUY_MENU:
        shop_title = "Welcome to the Shop!\nWhat would you like to buy?\n"

        buy_menu(con, shop_title, player, 50, screen_width, screen_height)

    elif game_state == GameStates.SHOP_MENU:
        shop_title = "Welcome to the Shop!\nWhat would you like to do?\n"

        shop_menu(con, shop_title, player, 50, screen_width, screen_height)
Beispiel #30
0
def render_all(con, panel, entities, player, game_map, fov_map, fov_recompute,
               message_log, screen_width, screen_height, bar_width,
               panel_height, panel_y, mouse, colors, game_state):
    '''
    Renders everything needed in game
    '''
    for y in range(game_map.height):
        for x in range(game_map.width):
            visible = libtcod.map_is_in_fov(fov_map, x, y)
            wall = game_map.tiles[x][y].block_sight

            if visible:
                if wall:
                    libtcod.console_set_char_background(
                        con, x, y, colors.get('light_wall'), libtcod.BKGND_SET)
                else:
                    libtcod.console_set_char_background(
                        con, x, y, colors.get('light_ground'),
                        libtcod.BKGND_SET)

                game_map.tiles[x][y].explored = True

            elif game_map.tiles[x][y].explored:
                if wall:
                    libtcod.console_set_char_background(
                        con, x, y, colors.get('dark_wall'), libtcod.BKGND_SET)
                else:
                    libtcod.console_set_char_background(
                        con, x, y, colors.get('dark_ground'),
                        libtcod.BKGND_SET)

    entities_in_render_order = sorted(entities,
                                      key=lambda x: x.render_order.value)
    # draw all entities in the list
    for entity in entities_in_render_order:
        draw_entity(con, entity, fov_map, game_map)

    libtcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)

    libtcod.console_set_default_background(panel, libtcod.black)
    libtcod.console_clear(panel)

    # print game messages, one line at a time
    y = 1
    for message in message_log.messages:
        libtcod.console_set_default_foreground(panel, message.color)
        libtcod.console_print_ex(panel, message_log.x, y, libtcod.BKGND_NONE,
                                 libtcod.LEFT, message.text)
        y += 1

    # HP bar
    render_bar(panel, 1, 1, bar_width, 'HP', player.fighter.hp,
               player.fighter.max_hp, libtcod.light_red, libtcod.darker_red)

    # bar for dungeon level
    libtcod.console_print_ex(
        panel, 1, 3, libtcod.BKGND_NONE, libtcod.LEFT,
        'Dungeon level: {0}'.format(game_map.dungeon_level))

    libtcod.console_set_default_foreground(panel, libtcod.light_gray)
    libtcod.console_print_ex(panel, 1, 0, libtcod.BKGND_NONE, libtcod.LEFT,
                             get_names_under_mouse(mouse, entities, fov_map))

    libtcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0,
                         panel_y)

    # renders inventory menu
    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
            inventory_title = 'Press key next to item to use, or Esc to cancel\n'
        else:
            inventory_title = 'Press key next to item to drop, or Esc to cancel\n'

        inventory_menu(con, inventory_title, player, 50, screen_width,
                       screen_height)

    # renders level up menu
    elif game_state == GameStates.LEVEL_UP:
        level_up_menu(con, 'Level up! Choose a stat to raise:\n', player, 40,
                      screen_width, screen_height)

    # renders character screen menu
    elif game_state == GameStates.CHARACTER_SCREEN:
        character_screen(player, 30, 10, screen_width, screen_height)

    # renders shop entrance menu
    elif game_state == GameStates.ENTER_SHOP:
        enter_shop_menu(con, 'Welcome to the shop!\n', player, 40,
                        screen_width, screen_height)

    # renders buying menu for shop
    elif game_state == GameStates.BUYING:
        for entity in entities:
            if entity.shopkeep:
                entity_to_send = entity
        buy_menu(con, '', entity_to_send, 50, screen_width, screen_height)

    # renders selling menu for shop
    elif game_state == GameStates.SELLING:
        sell_menu(con, '', player, 50, screen_width, screen_height)

    # renders rules screen
    elif game_state == GameStates.RULES:
        # open background image
        rules_background = libtcod.image_load('./art/rules_background.png')
        rules_menu(player, rules_background, screen_width, screen_height)
Beispiel #31
0
def render_all(con, panel, entities, player, game_map, fov_map, fov_recompute,
               message_log, screen_width, screen_height, bar_width,
               panel_height, panel_y, colors, game_state, current_enemy,
               player_target):
    if fov_recompute:
        for y in range(game_map.height):
            for x in range(game_map.width):
                visible = tcod.map_is_in_fov(fov_map, x, y)
                wall = game_map.tiles[x][y].block_sight

                if visible:
                    if wall:
                        tcod.console_set_char_background(
                            con, x, y, colors.get('light_wall'),
                            tcod.BKGND_SET)
                    else:
                        tcod.console_set_char_background(
                            con, x, y, colors.get('light_ground'),
                            tcod.BKGND_SET)

                    game_map.tiles[x][y].explored = True
                elif game_map.tiles[x][y].explored:
                    if wall:
                        tcod.console_set_char_background(
                            con, x, y, colors.get('dark_wall'), tcod.BKGND_SET)
                    else:
                        tcod.console_set_char_background(
                            con, x, y, colors.get('dark_ground'),
                            tcod.BKGND_SET)
                elif game_state != GameStates.SHOW_INVENTORY:
                    tcod.console_set_char_background(con, x, y,
                                                     colors.get('black'),
                                                     tcod.BKGND_SET)
                    tcod.console_put_char(con, x, y, ' ', tcod.BKGND_NONE)

    entities_in_render_order = sorted(entities,
                                      key=lambda x: x.render_order.value)

    for entity in entities_in_render_order:
        draw_entity(con, entity, fov_map)

    tcod.console_set_default_background(panel, tcod.black)
    tcod.console_clear(panel)

    y = 1
    for message in message_log.messages:
        tcod.console_set_default_foreground(panel, message.color)
        tcod.console_print_ex(panel, message_log.x, y, tcod.BKGND_NONE,
                              tcod.LEFT, message.text)
        y += 1

    render_bar(panel, 1, 1, bar_width, 'HP', player.fighter.hp,
               player.fighter.max_hp, tcod.light_red, tcod.darker_red)
    if current_enemy:
        render_bar(con,
                   int(screen_width / 2) - int(bar_width / 2), 1, bar_width,
                   'HP', player.current_enemy.hp, player.current_enemy.max_hp,
                   tcod.light_red, tcod.darker_red)

    if game_state in (GameStates.LOOKING, GameStates.TARGETING):
        tcod.console_set_char_background(con, player_target.x, player_target.y,
                                         tcod.light_gray, tcod.BKGND_SET)
        tcod.console_set_default_foreground(panel, tcod.light_gray)
        tcod.console_print_ex(
            panel, 1, 0, tcod.BKGND_NONE, tcod.LEFT,
            get_names_at_target(entities, fov_map, player_target))

    tcod.console_blit(con, 0, 0, screen_width, screen_height, 0, 0, 0)

    tcod.console_blit(panel, 0, 0, screen_width, panel_height, 0, 0, panel_y)

    if game_state in (GameStates.SHOW_INVENTORY, GameStates.DROP_INVENTORY):
        if game_state == GameStates.SHOW_INVENTORY:
            inventory_title = 'Press the key next to an item to use it, or use Esc to cancel.\n'
        elif game_state == GameStates.DROP_INVENTORY:
            inventory_title = 'Press the key next to an item to drop it, or use Esc to cancel.\n'

        inventory_menu(con, inventory_title, player.inventory, 50,
                       screen_width, screen_height)