im trying to make a real time strategy game such as starcraft or age of empires. my maps woud have to support up to about 1500 entities. My problem arrises with how to implement a fog of war without lagging the game. The method that i initialy tried was to simply caclulate the distance to all surrounding area of a unit everytime it moved but as i expected this lagged since many units would be constantly moving. If anyone knows a faster algorythim for a fog of war please help. the maps would be tile based and stored in an array.
A quite basic implementation can be as follows:
Visibility is given by a value v[i,j]
for each tile (i,j)
. Any value below a certain threshold lies within the fog.
The values are updated with regular time steps (note: for such a thing no high accuracy or high frequency is needed besides for very special cases) using the following two steps:
v[i,j]
unit
increase the value v[unit_i, unit_j]
by a constant amount. You can also add a constant amount if a unit is on a square (no matter how many of them are there).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With