Пример #1
0
 def compute_fov(self):
   for x in range (M.MAP_WIDTH):
     for y in range (M.MAP_HEIGHT):
       if M.gameworld[x][y].is_floor():
        libtcod.map_set_properties (self.fov, x , y, True, True)
   libtcod.map_compute_fov (self.fov, self.x, self.y, self.view_distance,
                           True,libtcod.FOV_DIAMOND)
Пример #2
0
 def ini_fov_map(self):
     """
     Inits the FOV map for player's current level.
     """
     self.fov_map = tcod.map_new(self.curlevel[0].mapa.w, self.curlevel[0].mapa.h)
     for y in range(self.curlevel[0].mapa.h):
         for x in range(self.curlevel[0].mapa.w):
             tcod.map_set_properties(self.fov_map, x, y, not TILETYPES[self.curlevel[0].mapa.mapa[x][y].tipo]['block_sight'], not TILETYPES[self.curlevel[0].mapa.mapa[x][y].tipo]['block_pass'])
Пример #3
0
 def __init__(self, width=MAP_WIDTH, height=MAP_HEIGHT):
     self.width = width
     self.height = height
     self.tiles = [[Tile('wall')
                     for y in range(self.height)]
                         for x in range(self.width)]
     self.fov_map = libtcod.map_new(self.width, self.height)
             
     self.objects = []                            
     self.rooms = []
     self.num_rooms = 0
     
     for r in range(MAX_ROOMS):
         w = libtcod.random_get_int(0, ROOM_MIN_SIZE, ROOM_MAX_SIZE)
         h = libtcod.random_get_int(0, ROOM_MIN_SIZE, ROOM_MAX_SIZE)
         x = libtcod.random_get_int(0, 0, MAP_WIDTH - w - 1)
         y = libtcod.random_get_int(0, 0, MAP_HEIGHT - h - 1)
         
         new_room = Rect(x, y, w, h)
         
         failed = False
         for other_room in self.rooms:
             if new_room.intersect(other_room):
                 failed = True
                 break
         
         if not failed:
             self.create_room(new_room)
             self.generate_room_objects(new_room)
             (new_x, new_y) = new_room.center()
             
             if self.num_rooms == 0:
                 self.start_x = new_x
                 self.start_y = new_y
             else:
                 self.join_rooms(new_room, self.rooms[-1])
             self.end_x = new_x
             self.end_y = new_y
             
             self.rooms.append(new_room)
             self.num_rooms += 1
             
     self.tiles[self.start_x][self.start_y].type = tiletypes['up_stairs']
     self.tiles[self.end_x][self.end_y].type = tiletypes['down_stairs']
     
     for y in range(self.height):
         for x in range(self.width):
             libtcod.map_set_properties(self.fov_map, 
                                        x, y, 
                                        not self.tiles[x][y].type.block_sight, 
                                        not self.tiles[x][y].type.blocked)
Пример #4
0
 def _update_fov(self, x, y):
   libtcod.map_set_properties(self.fov, x, y,
                               not self.is_wall(x, y),
                               not self.is_blocked(x, y))
 def create_fov_map(self):
     for x, y in self.coords():
         t = self.level[x][y]
         ltc.map_set_properties(self.fov_map, x, y, t.transparent,
                                t.passable)
Пример #6
0
	def create_fov_map (self):
		"""	Create the fov map """
		self.fov = libtcod.map_new(self.width, self.height)
		for x, y in self:
			libtcod.map_set_properties(self.fov, x, y, not self.tiles[x][y].filled, self.tiles[x][y].is_filled)