For the Fog you might want to "gray out" the tiles that are out of sight (or just not in LOS), and with that hide all objects that are on that tile... then people will clerly recognize it as dynamic fog of war.
I added the LOS algorithm I use in my project. It uses the Bresenheim (Bresenham) Algorithm for the calculation of an integer line, which is I think the fastest on the world (update: there have been variatons of it that are up to 10x faster than the original:
http://forum.thegamecreators.com/?m=forum_view&t=72850&b=1 <- DBP translation by JessTicular). Note that it uses INTEGERs, dont replace them with floats, as it is one of the reasons why it is so fast.
In my code there are two arrays used:
1) tiles_visible (x,y) as integer
2) TileArray(x,y) As TILE
1)this is just a boolean array that will store the result of the calculation, it is not as big as the 2nd, since you only have to check until you reach the RANGE OF SIGHT.
2) this is a 2d array that holds all tiles of the map. it is used to check whether a tile is blocking your view or not.
The Algorithm in words:
You pass him two Points, the start and end of a line.
The algorithm will then go from the start till the end, check if the current tile is not wall (meaning you can see through it), sets 1 to tiles_visible, OR exits the function if not. (rest will be 0).
SO in your game you will have to call the line function for all your points ON THE EDGE of your Sight range, where the char position is the start of the line. And before you do the calculation, undim the tiles_visible array and redim it, to make sure all bits are set to 0 (not visible).
So now you can do this I hope, and it will still require enough brain work from your side, but this is good I guess, if not (I may have missed to explain an important thing), just ask! I will be keeping an eye on this project. AND I will also make a function using bresenheim's algorithm to calculate an integer circle, which you could alos use to determine the outher part of your sight range.
Ok enough for now. Good Luck implementing!
greets,
Barnski.
edit: forgot the code, so I insert it here:
edit2: Don't try to UNDERSTAND the math, it is the result of a complex theory of Bresenheim... I just implemented it in DBP
function check_line(l_xP as integer, l_yP as integer, l_xQ as integer, l_yQ as integer)
l_x = l_xP
l_y = l_yP
l_D = 0
l_HX = l_xQ - l_xP
l_HY = l_yQ - l_yP
l_xInc = 1
l_yInc = 1
if l_HX < 0
l_xInc = -1
l_HX = -l_HX
endif
if l_HY < 0
l_yInc = -1
l_HY = -l_HY
endif
if l_HY <= l_HX
l_c = 2 * l_HX
l_M = 2 * l_HY
while 1
tiles_visible(g_RangeOfSight + l_x - l_xP, g_RangeOfSight + l_y - l_yP) = 1
if TileTyp(TileArray(l_x, l_y).Tile) = 1 or l_x = l_xQ then exit
l_x = l_x + l_xInc
l_D = l_D + l_M
if l_D > l_HX
l_y = l_y + l_yInc
l_D = l_D - l_c
endif
endwhile
else
l_c = 2 * l_HY
l_M = 2 * l_HX
while 1
tiles_visible(g_RangeOfSight + l_x - l_xP, g_RangeOfSight + l_y - l_yP) = 1
if TileTyp(TileArray(l_x, l_y).Tile) = 1 or l_y = l_yQ then exit
l_y = l_y + l_yInc
l_D = l_D + l_M
if l_D > l_HY
l_x = l_x + l_xInc
l_D = l_D - l_c
endif
endwhile
endif
endfunction
-- I just started with DarkSDK, by translating DBP Projects. --