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'])
def __init__(self, width, height, colors): self.width = width self.height = height self.colors = colors self.tiles = [[ Tile(True) for y in range(height)] for x in range(width)] self.fov = libtcod.map_new(width, height) for y in range(self.height): for x in range(self.width): self._update_fov(x, y)
def __init__(self, w, h, level, rooms, objects=None, player=None): self.w = w self.h = h self.level = level self.rooms = rooms self.objects = objects if objects else [] self.player = player self.fov_map = ltc.map_new(w, h) self.create_fov_map()
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)
def __init__ (self, name, max_health, x, y, char, color, view_distance=10, strength=5, to_hit=0.8): self.name = name self.health = max_health self.max_health = max_health self.x = x self.y = y self.char = char self.color = color self.items = [] self.equipped = list() self.hand = None self.view_distance = view_distance self.strength = strength self.to_hit = to_hit self.fov = libtcod.map_new(M.MAP_WIDTH, M.MAP_HEIGHT) self.npc = False self.exp = 0 M.gameworld[self.x][self.y].characters.append(self) self.compute_fov()
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)