def see_player(self): player = self.map.player see_range = self.fov_range #if it's intelligent one - let it follow source of light if self.flags & INTELLIGENT: see_range += player.fov_range / 2 if libtcod.map_is_in_fov(self.map.fov_map, self.x, self.y): d = util.distance(self.x, self.y, player.x, player.y) if d <= see_range: return d return None
def render_all(self, map, player): if gl.__fov_recompute__: gl.__fov_recompute__ = False map.recompute_fov() for y in range(map.map_height): for x in range(map.map_width): seen = map.map[y][x].seen | gl.__wizard_mode__ visible = libtcod.map_is_in_fov(map.fov_map, x, y) #if tile is seen or visible to player - print it if seen or visible: libtcod.console_print_left(self.con, x, y, libtcod.BKGND_NONE, map[y][x].char) #if it's not in LOS, but seen - print in dim color if not visible: if seen: libtcod.console_set_fore(self.con, x, y, self.create_color(map[y][x].dim_color)) libtcod.console_set_back(self.con, x, y, self.create_color(map[y][x].dim_color_back), libtcod.BKGND_SET) else: #if it's in LOS - print and mark as seen libtcod.console_set_fore(self.con, x, y, self.create_color(map[y][x].color)) libtcod.console_set_back(self.con, x, y, self.create_color(map[y][x].color_back), libtcod.BKGND_SET) #if current tile is visible for now - mark as seen map[y][x].seen = True for critter in map.map_critters: if libtcod.map_is_in_fov(map.fov_map, critter.x, critter.y) or gl.__wizard_mode__: libtcod.console_set_foreground_color(self.con, self.create_color(critter.color)) self.print_critter(critter.x, critter.y, critter.char) libtcod.console_set_foreground_color(self.con, self.create_color(player.color)) self.print_critter(player.x, player.y, player.char) if gl.__wizard_mode__: libtcod.console_print_left(self.con, 0, 0, libtcod.BKGND_NONE, 'WIZ MODE') libtcod.console_blit(self.con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0) libtcod.console_flush()