So far so good. I've managed to get the player discovering a circle around him.
Thing is, I would like that it only discovers till it hits a wall.
How can I make this? Draw a line to each tile from the player position and see if it hits a wall?
This is what I have so far for the circular sight.
void discover_area(const Vector2i& center, int radius)
{
int left = center.X - radius < 0 ? -center.X : -radius;
int right = center.X + radius >= _n_tiles.X ? _n_tiles.X - center.X : radius+1;
int top = center.Y - radius < 0 ? -center.Y : -radius;
int bottom = center.Y + radius >= _n_tiles.Y ? _n_tiles.Y - center.Y : radius+1;
int range2 = radius*radius;
for (int y = top; y < bottom; y++)
{
for (int x = left; x < right; x++)
{
if (x*x + y*y <= range2)
{
_tiles[center.X+x][center.Y+y]->discover();
}
}
}
}