Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Monster:fov()
- local x, y
- self.visible_tiles = {}
- for i = 1, self.current_dungeon.size.w do
- self.visible_tiles[i] = {}
- for j = 1, self.current_dungeon.size.h do
- self.visible_tiles[i][j] = 0
- end
- end
- for i = 0, 360 do
- x = math.cos(i * 0.01745)
- y = math.sin(i * 0.01745)
- self:do_fov(x, y)
- end
- end
- function Monster:do_fov(x, y)
- local ox, oy
- ox = self.pos.x + 0.5
- oy = self.pos.y + 0.5
- for i = 0, self.view_radius do
- self.visible_tiles[math.ceil(ox)][math.ceil(oy)] = self.view_radius - (i * 1.7)
- if self.visible_tiles[math.ceil(ox)][math.ceil(oy)] <= 0 then
- self.visible_tiles[math.ceil(ox)][math.ceil(oy)] = 0
- end
- if self.current_dungeon.tiles[math.ceil(ox)][math.ceil(oy)].solid then
- return
- end
- ox = ox + x
- oy = oy + y
- end
- end
Add Comment
Please, Sign In to add comment