Exemplo n.º 1
0
def draw_objects():
    """
        Place all map objects on the canvas.
    """
    # items and non-NPC's
    for obj in [e for e in game_objects if not isinstance(e, cls.AnimalBase)]:
        if obj.x > 0:   #TODO replace with a visible property
            if player.wizard or libtcod.map_is_in_fov(fov_map, obj.x, obj.y):
                player.msg("You see %c%s%c" % (C.COL3, obj.name, C.COLS)
                                                , allow_duplicates=False)
                libtcod.console_put_char_ex(canvas, obj.x, obj.y, 
                                            obj.char, obj.fgcolor, obj.bgcolor)
    
    # NPC's
    for obj in [e for e in game_objects if isinstance(e, cls.AnimalBase) and 
        not isinstance(e, cls.Player)]:
        if obj.x > 0:   #TODO replace with a visible property
            if player.wizard or libtcod.map_is_in_fov(fov_map, obj.x, obj.y):
                player.msg("You see %c%s%c" % (C.COL4, obj.name, C.COLS)
                                                , allow_duplicates=False)
                if obj.see_message:
                    player.msg("%c%s%c" % (C.COL2, obj.see_message, C.COLS)
                                                ,allow_duplicates=False)
                # draw the NPC background color to match the map
                libtcod.console_put_char_ex(canvas, obj.x, obj.y, 
                                            obj.char, obj.fgcolor
                                            , game_map[obj.x][obj.y].bgcolor)
    # draw player to match the map background
    libtcod.console_put_char_ex(canvas, player.x, player.y, 
                                player.char, player.fgcolor
                                , game_map[player.x][player.y].bgcolor)
Exemplo n.º 2
0
    def render_map(self, player, dmap):
        camera = self.camera
        con = self.map_console

        # Clear screen before redraw
        libtcod.console_clear(con)

        camera.move(player.x, player.y)
        dmap.recompute_fov(player.x, player.y)
        for x in range(camera.width):
            for y in range(camera.height):
                (map_x, map_y) = (camera.x + x, camera.y + y)

                tile = dmap[map_x][map_y]
                in_fov = libtcod.map_is_in_fov(dmap.fov_map, map_x, map_y)
                self.draw_tile(x, y, tile, in_fov)

        for obj in dmap.objects:
            if obj != player:
                if libtcod.map_is_in_fov(dmap.fov_map, obj.x, obj.y):
                    (x, y) = camera.convert_coordinates(obj.x, obj.y)
                    self.draw_obj(con, x, y, obj)
        (x, y) = camera.convert_coordinates(player.x, player.y)
        self.draw_obj(con, x, y, player)

        return con
Exemplo n.º 3
0
 def take_turn(self, game_map, fov_map, path_map, game_objects, playerxy):
     npc = self.owner
     x, y = (0, 0)
     if self.behaviour == MoveAI.SKITTISH:
         if dice(2):
             npc.move(game_map, game_objects, random.randint(-1, 1), random.randint(-1, 1))
         else:
             x, y = playerxy
             libtcod.map_compute_fov(fov_map, npc.x, npc.y, npc.fov_radius
                                             ,C.FOV_LIGHT_WALLS, C.FOV_ALGO)
             if libtcod.map_is_in_fov(fov_map, x, y):
                 # player in sight!
                 if libtcod.path_compute(path_map, npc.x, npc.y, x, y):
                     x, y = libtcod.path_walk(path_map, True)
                     if not x is None:
                         npc.move(game_map, game_objects, npc.x - x, npc.y - y)
     elif self.behaviour == MoveAI.NEUTRAL:
         if dice(self.erraticity):
             x = random.randint(-1, 1)
         if dice(self.erraticity):
             y = random.randint(-1, 1)
         npc.move(game_map, game_objects, x, y)
     elif self.behaviour == MoveAI.FRIENDLY:
         x, y = playerxy
         # player in sight!
         if libtcod.path_compute(path_map, npc.x, npc.y, x, y):
             # stick a little bit away
             if libtcod.path_size(path_map) > 3:
                 x, y = libtcod.path_walk(path_map, True)
                 if not x is None:
                     npc.move(game_map, game_objects, x - npc.x, y - npc.y)
     elif self.behaviour == MoveAI.HUNTING:
         # look for prey
         x, y = playerxy
         libtcod.map_compute_fov(fov_map, npc.x, npc.y, npc.fov_radius
                                         ,C.FOV_LIGHT_WALLS, C.FOV_ALGO)
         if libtcod.map_is_in_fov(fov_map, x, y):
             # player in sight!
             if libtcod.path_compute(path_map, npc.x, npc.y, x, y):
                 self.prey_x = x
                 self.prey_y = y
                 x, y = libtcod.path_walk(path_map, True)
                 if not x is None:
                     npc.move(game_map, game_objects, x - npc.x, y - npc.y)
         else:
             # prowl last know prey location
             if libtcod.path_compute(path_map, npc.x, npc.y
                                     ,self.prey_x, self.prey_y):
                 x, y = libtcod.path_walk(path_map, True)
                 if not x is None:
                     npc.move(game_map, game_objects, x - npc.x, y - npc.y)
Exemplo n.º 4
0
    def draw(self):
        #set the color and then draw the character that represents this object at its position
        if libtcod.map_is_in_fov(fov_map, self.x, self.y):

            libtcod.console_set_foreground_color(con, self.color)
            libtcod.console_put_char(con, self.x, self.y, self.char,
                                     libtcod.BKGND_NONE)
Exemplo n.º 5
0
def render_all():
    global fov_map, color_dark_wall, color_light_wall, color_dark_ground, color_light_ground, fov_recompute

    if fov_recompute:
        #recompute FOV if needed
        fov_recompute = False
        libtcod.map_compute_fov(fov_map, player.x, player.y, TORCH_RADIUS,
                                FOV_LIGHT_WALLS, FOV_ALGO)

        for y in range(MAP_HEIGHT):
            for x in range(MAP_WIDTH):
                visible = libtcod.map_is_in_fov(fov_map, x, y)
                wall = map[x][y].block_sight
                if not visible:
                    if map[x][y].explored:
                        if wall:
                            libtcod.console_put_char_ex(
                                con, x, y, '#', color_dark_wall, libtcod.black)

                        else:
                            libtcod.console_put_char_ex(
                                con, x, y, '.', color_dark_ground,
                                libtcod.black)
                else:
                    if wall:
                        libtcod.console_put_char_ex(con, x, y, '#',
                                                    color_light_wall,
                                                    libtcod.black)
                    else:
                        libtcod.console_put_char_ex(con, x, y, '.',
                                                    color_light_ground,
                                                    libtcod.black)
                    map[x][y].explored = True

    #draw everything
    for stuff in objects:
        if stuff != player:
            stuff.draw()
    player.draw()
    #we are "blitting" our offscreen console oot the root console
    libtcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0)

    #render GUI
    libtcod.console_set_background_color(panel, libtcod.black)
    libtcod.console_clear(panel)

    #print game messages
    y = 1
    for (line, color) in game_msgs:
        libtcod.console_set_foreground_color(panel, color)
        libtcod.console_print_left(panel, MSG_X, y, libtcod.BKGND_NONE, line)
        y += 1

    #show player stats
    render_bar(1, 1, BAR_WIDTH, 'HP', player.fighter.hp, player.fighter.max_hp,
               libtcod.light_red, libtcod.darker_red)

    #blit onto root console
    libtcod.console_blit(panel, 0, 0, SCREEN_WIDTH, PANEL_HEIGHT, 0, 0,
                         PANEL_Y)
Exemplo n.º 6
0
def render_all(fov_map):
    world.draw(fov_map)

    for object in objects:
        if libtcod.map_is_in_fov(fov_map, object.x, object.y):
            object.draw()

    libtcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0)
Exemplo n.º 7
0
 def draw(self, fov_map):
     for y in range(self.map_height):
         for x in range(self.map_width):
             tile = self.level[x][y]
             in_fov = libtcod.map_is_in_fov(fov_map, x, y)
             if in_fov:
                 tile.explored = True
             if tile.explored:
                 self.draw_tile(tile, x, y, in_fov)
 def draw(self):
     # only show if it's visible to the player; or it's set to
     # "always visible" and on an explored tile
     if (libtcod.map_is_in_fov(fov_map, self.x, self.y) or
             (self.always_visible and map[self.x][self.y].explored)):
         # set the color and then draw the character that represents
         # this object at its position
         libtcod.console_set_default_foreground(con, self.color)
         libtcod.console_put_char(con, self.x, self.y, self.char,
                                  libtcod.BKGND_NONE)
Exemplo n.º 9
0
    def take_turn(self):
        #a basic monster takes its turn. if you can see it, it can see you
        if libtcod.map_is_in_fov(fov_map, self.owner.x, self.owner.y):

            #move towards player if far away
            if self.owner.distance_to(player) >= 2:
                self.owner.move_towards(player.x, player.y)

            #close enough, attack! (if the player is still alive.)
            elif player.hp > 0:
                self.owner.attack(player)
Exemplo n.º 10
0
def get_names_under_mouse():
    #return a string with the names of all objects under the mouse
    mouse = libtcod.mouse_get_status()
    (x, y) = (mouse.cx, mouse.cy)
 
    #create a list with the names of all objects at the mouse's coordinates and in FOV
    names = [obj.name for obj in objects
        if obj.x == x and obj.y == y and libtcod.map_is_in_fov(fov_map, obj.x, obj.y)]
 
    names = ', '.join(names)  #join the names, separated by commas
    return names.capitalize()
Exemplo n.º 11
0
 def draw(self):
     #only show if it's visible to the player
     in_fov = libtcod.map_is_in_fov(fov_map, self.x, self.y)
     if (self.ai == None and self.seen) or in_fov:
         #set the color and then draw the character that represents this object at its position
         self.seen = True
         if in_fov:
             libtcod.console_set_foreground_color(con, self.color)
         else:
             libtcod.console_set_foreground_color(con, libtcod.grey)
         libtcod.console_put_char(con, self.x, self.y, self.char, libtcod.BKGND_NONE)
Exemplo n.º 12
0
    def take_turn(self):
        #a basic monster takes its turn. if you can see it, it can see you
        if libtcod.map_is_in_fov(fov_map, self.owner.x, self.owner.y):
 
            #move towards player if far away
            if self.owner.distance_to(player) >= 2:
                self.owner.move_towards(player.x, player.y)
 
            #close enough, attack! (if the player is still alive.)
            elif player.hp > 0:
                self.owner.attack(player)
Exemplo n.º 13
0
	def take_turn(self):
		monster = self.owner
		
		if libtcod.map_is_in_fov(fov_map, monster.x, monster.y):

			#move towards player
			if monster.distance_to(player) >= 2:
				monster.move_towards(player.x, player.y)

			#close enough to attack
			elif player.fighter.hp > 0:
				monster.fighter.attack(player)
Exemplo n.º 14
0
    def take_turn(self):
        monster = self.owner

        if libtcod.map_is_in_fov(fov_map, monster.x, monster.y):

            #move towards player
            if monster.distance_to(player) >= 2:
                monster.move_towards(player.x, player.y)

            #close enough to attack
            elif player.fighter.hp > 0:
                monster.fighter.attack(player)
Exemplo n.º 15
0
 def draw(self):
     #only show if it's visible to the player
     in_fov = libtcod.map_is_in_fov(fov_map, self.x, self.y)
     if (self.ai == None and self.seen) or in_fov:
         #set the color and then draw the character that represents this object at its position
         self.seen = True
         if in_fov:
             libtcod.console_set_foreground_color(con, self.color)
         else:
             libtcod.console_set_foreground_color(con, libtcod.grey)
         libtcod.console_put_char(con, self.x, self.y, self.char,
                                  libtcod.BKGND_NONE)
Exemplo n.º 16
0
def closest_monster(max_range):
	#find nearest enemy
	closest_enemy = None
	closest_dist = max_range + 1

	for object in objects:
		if object.fighter and not object == player and libtcod.map_is_in_fov(fov_map, object.x, object.y):
			#find distance
			dist = player.distance_to(object)
			if dist < closest_dist:
				closest_enemy = object
				closest_dist = dist
	return closest_enemy
Exemplo n.º 17
0
def get_names_under_mouse():
    #return a string with the names of all objects under the mouse
    mouse = libtcod.mouse_get_status()
    (x, y) = (mouse.cx, mouse.cy)

    #create a list with the names of all objects at the mouse's coordinates and in FOV
    names = [
        obj.name for obj in objects if obj.x == x and obj.y == y
        and libtcod.map_is_in_fov(fov_map, obj.x, obj.y)
    ]

    names = ', '.join(names)  #join the names, separated by commas
    return names.capitalize()
Exemplo n.º 18
0
def closest_monster(max_range):
    #find closest enemy, up to a maximum range, and in the player's FOV
    closest_enemy = None
    closest_dist = max_range + 1  #start with (slightly more than) maximum range
 
    for object in objects:
        if isinstance(object, Fighter) and not object == player and libtcod.map_is_in_fov(fov_map, object.x, object.y):
            #calculate distance between this object and the player
            dist = player.distance_to(object)
            if dist < closest_dist:  #it's closer, so remember it
                closest_enemy = object
                closest_dist = dist
    return closest_enemy
Exemplo n.º 19
0
def render_all():
	global fov_map, color_dark_wall, color_light_wall, color_dark_ground, color_light_ground, fov_recompute
	
	if fov_recompute:
		#recompute FOV if needed
		fov_recompute = False
		libtcod.map_compute_fov(fov_map, player.x, player.y, TORCH_RADIUS, FOV_LIGHT_WALLS, FOV_ALGO)	

	
		for y in range(MAP_HEIGHT):
			for x in range(MAP_WIDTH):
				visible = libtcod.map_is_in_fov(fov_map, x, y)
				wall = map[x][y].block_sight
				if not visible:
					if map[x][y].explored:
						if wall:
							libtcod.console_put_char_ex(con, x, y, '#', color_dark_wall, libtcod.black)

						else:
							libtcod.console_put_char_ex(con, x, y, '.', color_dark_ground, libtcod.black)
				else:
					if wall:
						libtcod.console_put_char_ex(con, x, y, '#', color_light_wall, libtcod.black)
					else:
						libtcod.console_put_char_ex(con, x, y, '.', color_light_ground, libtcod.black)
					map[x][y].explored = True
	
	#draw everything
	for stuff in objects:
		if stuff != player:
			stuff.draw()
	player.draw()
	#we are "blitting" our offscreen console oot the root console
	libtcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0)

	#render GUI
	libtcod.console_set_background_color(panel, libtcod.black)
	libtcod.console_clear(panel)

	#print game messages
	y = 1
	for (line, color) in game_msgs:
		libtcod.console_set_foreground_color(panel, color)
		libtcod.console_print_left(panel, MSG_X, y, libtcod.BKGND_NONE, line)
		y += 1

	#show player stats
	render_bar(1, 1, BAR_WIDTH, 'HP', player.fighter.hp, player.fighter.max_hp, libtcod.light_red, libtcod.darker_red)

	#blit onto root console
	libtcod.console_blit(panel, 0, 0, SCREEN_WIDTH, PANEL_HEIGHT, 0, 0, PANEL_Y)
Exemplo n.º 20
0
def draw_map():
    """
        Draw the map tiles onto the canvas.
    """
    for y in range(C.MAP_HEIGHT - 0):
        for x in range(C.MAP_WIDTH - 0):
            tile = game_map[x][y]
            if player.wizard or libtcod.map_is_in_fov(fov_map, x, y):
                tile.seen = True
                libtcod.console_put_char_ex(canvas, x, y, 
                                            tile.char, tile.fgcolor, tile.bgcolor)
            elif tile.seen:
                libtcod.console_put_char_ex(canvas, x, y, tile.char
                                        ,libtcod.black, libtcod.darkest_grey)
Exemplo n.º 21
0
def closest_monster(max_range):
    #find nearest enemy
    closest_enemy = None
    closest_dist = max_range + 1

    for object in objects:
        if object.fighter and not object == player and libtcod.map_is_in_fov(
                fov_map, object.x, object.y):
            #find distance
            dist = player.distance_to(object)
            if dist < closest_dist:
                closest_enemy = object
                closest_dist = dist
    return closest_enemy
Exemplo n.º 22
0
def closest_monster(max_range):
    #find closest enemy, up to a maximum range, and in the player's FOV
    closest_enemy = None
    closest_dist = max_range + 1  #start with (slightly more than) maximum range

    for object in objects:
        if isinstance(
                object,
                Fighter) and not object == player and libtcod.map_is_in_fov(
                    fov_map, object.x, object.y):
            #calculate distance between this object and the player
            dist = player.distance_to(object)
            if dist < closest_dist:  #it's closer, so remember it
                closest_enemy = object
                closest_dist = dist
    return closest_enemy
Exemplo n.º 23
0
def target_tile(max_range=None):
    #return the position of a tile left-clicked in player's FOV (optionally in a range), or (None,None) if right-clicked.
    while True:
        #render the screen. this erases the inventory and shows the names of objects under the mouse.
        render_graphics()
        libtcod.console_flush()
 
        key = libtcod.console_check_for_keypress()
        mouse = libtcod.mouse_get_status()  #get mouse position and click status
        (x, y) = (mouse.cx, mouse.cy)
 
        if mouse.rbutton_pressed or key.vk == libtcod.KEY_ESCAPE:
            return (None, None)  #cancel if the player right-clicked or pressed Escape
 
        #accept the target if the player clicked in FOV, and in case a range is specified, if it's in that range
        if (mouse.lbutton_pressed and libtcod.map_is_in_fov(fov_map, x, y) and
            (max_range is None or player.distance(x, y) <= max_range)):
            return (x, y)
Exemplo n.º 24
0
def target_tile(max_range=None):
    #return the position of a tile left-clicked in player's FOV (optionally in a range), or (None,None) if right-clicked.
    while True:
        #render the screen. this erases the inventory and shows the names of objects under the mouse.
        render_graphics()
        libtcod.console_flush()

        key = libtcod.console_check_for_keypress()
        mouse = libtcod.mouse_get_status(
        )  #get mouse position and click status
        (x, y) = (mouse.cx, mouse.cy)

        if mouse.rbutton_pressed or key.vk == libtcod.KEY_ESCAPE:
            return (None, None
                    )  #cancel if the player right-clicked or pressed Escape

        #accept the target if the player clicked in FOV, and in case a range is specified, if it's in that range
        if (mouse.lbutton_pressed and libtcod.map_is_in_fov(fov_map, x, y)
                and (max_range is None or player.distance(x, y) <= max_range)):
            return (x, y)
def target_tile(max_range=None):
    global key, mouse
    # return the position of a tile left-clicked in player's FOV
    # (optionally in a range), or (None,None) if right-clicked.
    while True:
        # render the screen. this erases the inventory and shows the
        # names of objects under the mouse.
        libtcod.console_flush()
        libtcod.sys_check_for_event(
            libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)
        render_all()

        (x, y) = (mouse.cx, mouse.cy)

        if mouse.rbutton_pressed or key.vk == libtcod.KEY_ESCAPE:
            # cancel if the player right-clicked or pressed Escape
            return (None, None)

        # accept the target if the player clicked in FOV, and in case
        # a range is specified, if it's in that range
        if (mouse.lbutton_pressed and libtcod.map_is_in_fov(fov_map, x, y) and
                (max_range is None or player.distance(x, y) <= max_range)):
            return (x, y)
Exemplo n.º 26
0
Arquivo: map.py Projeto: jimperio/pyrl
 def is_in_fov(self, x, y):
   return libtcod.map_is_in_fov(self.__fov_map, x, y)
Exemplo n.º 27
0
	def draw(self):
		#set the color and then draw the character that represents this object at its position
		if libtcod.map_is_in_fov(fov_map, self.x, self.y):

			libtcod.console_set_foreground_color(con, self.color)
			libtcod.console_put_char(con, self.x, self.y, self.char, libtcod.BKGND_NONE)
Exemplo n.º 28
0
def render_graphics():
    global fov_map, color_dark_wall, color_light_wall
    global color_dark_ground, color_light_ground
    global fov_recompute
    global emitters
    emitters = []
    global glosnosc
    glosnosc = {}

    if fov_recompute:
        #recompute FOV if needed (the player moved or something)
        fov_recompute = False
        libtcod.map_compute_fov(fov_map, player.x, player.y, TORCH_RADIUS, FOV_LIGHT_WALLS, FOV_ALGO)
 
        #go through all tiles, and set their background color according to the FOV
        for y in range(MAP_HEIGHT):
            for x in range(MAP_WIDTH):
                visible = libtcod.map_is_in_fov(fov_map, x, y)
                wall = map[x][y].block_sight

                if not visible:
                    #if it's not visible right now, the player can only see it if it's explored
                    if map[x][y].explored:
                        if wall:
                            libtcod.console_set_back(con, x, y, color_dark_wall, libtcod.BKGND_SET)
                        else:
                            libtcod.console_set_back(con, x, y, color_dark_ground, libtcod.BKGND_SET)
                else:
                    #it's visible
                    if wall:
                        libtcod.console_set_back(con, x, y, color_light_wall, libtcod.BKGND_SET )
                    else:
                        libtcod.console_set_back(con, x, y, color_light_ground, libtcod.BKGND_SET )
                    #since it's visible, explore it
                    map[x][y].explored = True

    #draw all objects in the list, except the player. we want it to
    #always appear over all other objects! so it's drawn later.
    for object in objects:
        if object != player:
            object.draw()
    player.draw()
 
    #blit the contents of "con" to the root console
    libtcod.console_blit(con, 0, 0, MAP_WIDTH, MAP_HEIGHT, 0, 0, 0)
 
    #prepare to render the GUI panel
    libtcod.console_set_background_color(panel, libtcod.black)
    libtcod.console_clear(panel)
 
    #print the game messages, one line at a time
    y = 1
    for (line, color) in game_msgs:
        libtcod.console_set_foreground_color(panel, color)
        libtcod.console_print_left(panel, MSG_X, y, libtcod.BKGND_NONE, line)
        y += 1

    #show the player's stats
    render_bar(1, 1, BAR_WIDTH, 'HP', player.hp, player.max_hp,
        libtcod.light_red, libtcod.darker_red)

    render_bar(1, 2, BAR_WIDTH, 'XP', player.xp, 100,
        libtcod.light_blue, libtcod.darker_blue)

    render_info(1, 4, BAR_WIDTH, 'Floor: ' + str(floor))
 
    #display names of objects under the mouse
    libtcod.console_set_foreground_color(panel, libtcod.light_gray)
    libtcod.console_print_left(panel, 1, 0, libtcod.BKGND_NONE, get_names_under_mouse())

    mouse = libtcod.mouse_get_status()
    (x1, y1) = (mouse.cx, mouse.cy)

    #print str(math.atan2(player.y-y1, player.x-x1)/math.pi*180)
 
    #blit the contents of "panel" to the root console
    libtcod.console_blit(panel, 0, 0, SCREEN_WIDTH, PANEL_HEIGHT, 0, 0, PANEL_Y)
Exemplo n.º 29
0
def render_graphics():
    global fov_map, color_dark_wall, color_light_wall
    global color_dark_ground, color_light_ground
    global fov_recompute
    global emitters
    emitters = []
    global glosnosc
    glosnosc = {}

    if fov_recompute:
        #recompute FOV if needed (the player moved or something)
        fov_recompute = False
        libtcod.map_compute_fov(fov_map, player.x, player.y, TORCH_RADIUS,
                                FOV_LIGHT_WALLS, FOV_ALGO)

        #go through all tiles, and set their background color according to the FOV
        for y in range(MAP_HEIGHT):
            for x in range(MAP_WIDTH):
                visible = libtcod.map_is_in_fov(fov_map, x, y)
                wall = map[x][y].block_sight

                if not visible:
                    #if it's not visible right now, the player can only see it if it's explored
                    if map[x][y].explored:
                        if wall:
                            libtcod.console_set_back(con, x, y,
                                                     color_dark_wall,
                                                     libtcod.BKGND_SET)
                        else:
                            libtcod.console_set_back(con, x, y,
                                                     color_dark_ground,
                                                     libtcod.BKGND_SET)
                else:
                    #it's visible
                    if wall:
                        libtcod.console_set_back(con, x, y, color_light_wall,
                                                 libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_back(con, x, y, color_light_ground,
                                                 libtcod.BKGND_SET)
                    #since it's visible, explore it
                    map[x][y].explored = True

    #draw all objects in the list, except the player. we want it to
    #always appear over all other objects! so it's drawn later.
    for object in objects:
        if object != player:
            object.draw()
    player.draw()

    #blit the contents of "con" to the root console
    libtcod.console_blit(con, 0, 0, MAP_WIDTH, MAP_HEIGHT, 0, 0, 0)

    #prepare to render the GUI panel
    libtcod.console_set_background_color(panel, libtcod.black)
    libtcod.console_clear(panel)

    #print the game messages, one line at a time
    y = 1
    for (line, color) in game_msgs:
        libtcod.console_set_foreground_color(panel, color)
        libtcod.console_print_left(panel, MSG_X, y, libtcod.BKGND_NONE, line)
        y += 1

    #show the player's stats
    render_bar(1, 1, BAR_WIDTH, 'HP', player.hp, player.max_hp,
               libtcod.light_red, libtcod.darker_red)

    render_bar(1, 2, BAR_WIDTH, 'XP', player.xp, 100, libtcod.light_blue,
               libtcod.darker_blue)

    render_info(1, 4, BAR_WIDTH, 'Floor: ' + str(floor))

    #display names of objects under the mouse
    libtcod.console_set_foreground_color(panel, libtcod.light_gray)
    libtcod.console_print_left(panel, 1, 0, libtcod.BKGND_NONE,
                               get_names_under_mouse())

    mouse = libtcod.mouse_get_status()
    (x1, y1) = (mouse.cx, mouse.cy)

    #print str(math.atan2(player.y-y1, player.x-x1)/math.pi*180)

    #blit the contents of "panel" to the root console
    libtcod.console_blit(panel, 0, 0, SCREEN_WIDTH, PANEL_HEIGHT, 0, 0,
                         PANEL_Y)
def render_all():
    global fov_map, color_dark_wall, color_light_wall
    global color_dark_ground, color_light_ground
    global fov_recompute

    if fov_recompute:
        # recompute FOV if needed (the player moved or something)
        fov_recompute = False
        libtcod.map_compute_fov(fov_map, player.x, player.y, TORCH_RADIUS,
                                FOV_LIGHT_WALLS, FOV_ALGO)

        # go through all tiles, and set their background color
        # according to the FOV
        for y in range(MAP_HEIGHT):
            for x in range(MAP_WIDTH):
                visible = libtcod.map_is_in_fov(fov_map, x, y)
                wall = map[x][y].block_sight
                if not visible:
                    # if it's not visible right now, the player can
                    # only see it if it's explored
                    if map[x][y].explored:
                        if wall:
                            libtcod.console_set_char_background(con, x, y,
                                                                color_dark_wall,
                                                                libtcod.BKGND_SET)
                        else:
                            libtcod.console_set_char_background(con, x, y,
                                                                color_dark_ground,
                                                                libtcod.BKGND_SET)
                else:
                    # it's visible
                    if wall:
                        libtcod.console_set_char_background(con, x, y,
                                                            color_light_wall,
                                                            libtcod.BKGND_SET)
                    else:
                        libtcod.console_set_char_background(con, x, y,
                                                            color_light_ground,
                                                            libtcod.BKGND_SET)
                        # since it's visible, explore it
                    map[x][y].explored = True

    # draw all objects in the list, except the player. we want it to
    # always appear over all other objects! so it's drawn later.
    for object in objects:
        if object != player:
            object.draw()
    player.draw()

    # blit the contents of "con" to the root console
    libtcod.console_blit(con, 0, 0, MAP_WIDTH, MAP_HEIGHT, 0, 0, 0)

    # prepare to render the GUI panel
    libtcod.console_set_default_background(panel, libtcod.black)
    libtcod.console_clear(panel)

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

    # show the player's stats
    render_bar(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 ' + str(dungeon_level))

    # display names of objects under the mouse
    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())

    # blit the contents of "panel" to the root console
    libtcod.console_blit(panel, 0, 0, SCREEN_WIDTH, PANEL_HEIGHT, 0, 0,
                         PANEL_Y)