As far as I know this is the first Fog of War snippet
Maybe you need this. Its for DBP
sync on
sync rate 60
set display mode 800,600,32
type Tank_m1a1
range as integer
speed as float
endtype
type Building_command_center
range as integer
endtype
dim m1a1(100) as Tank_m1a1
dim command(100) as Building_command_center
rem the view range of the first "tank"
for x=1 to 100
m1a1(x).range=10
m1a1(x).speed=0.5
next x
rem the view range of the first "command center"
for x=1 to 100
command(x).range=30
next x
rem the size of the map
maxx=512
maxy=512
rem the "lightmap"
make object plain 1,maxx*2,maxy*2
xrotate object 1,90
rem ghost object on 1,1
position object 1,maxx,2.5,maxy
set object 1,1,0,1
set object transparency 1,rgb(255,0,255)
rem the terrain
make object plain 2,maxx*2,maxy*2
xrotate object 2,90
position object 2,maxx,0,maxy
rem player object
make object box 3,2,4,2
rem players base
make object box 4,5,4,5
position object 4,100,0,100
rem some other players to find
for x=20 to 50
make object box x,2,2,2
position object x,rnd(maxx),0,rnd(maxy)
next x
gosub _build_image
rem color backdrop 0
update(object position x(4), object position z(4), 16)
update(object position x(3), object position z(3), 16)
position camera 100,100,100
do
ink rgb(255,255,0),0
set cursor 0,0
print "Mouse and arrowkeys to move the camera"
print "wasd to move the tank"
print "fps:: ",screen fps()
print "camera tilt: ",state
cx#=wrapvalue(cx#+mousemovey())
cy#=wrapvalue(cy#+mousemovex())
cz#=wrapvalue(cz#+mousemovez())
rotate camera cx#,cy#,cz#
if returnkey()=1 then inc state :r=1
if returnkey()=0 then r=0
if state>1 then state=0
if state=1
position camera 100,100,100
point camera object position x(3),object position y(3),object position z(3)
endif
if state=0
if upkey()=1 then move camera 4
if downkey()=1 then move camera -4
if inkey$()="w" then move object 3,m1a1(1).speed : position_updated = 1
if inkey$()="s" then move object 3,-m1a1(1).speed : position_updated = 1
if inkey$()="a" then turn object left 3,3
if inkey$()="d" then turn object right 3,3
if position_updated = 1
position_updated = 0
update(object position x(3), object position z(3),8)
endif
endif
sync
loop
function update(x,y, radius)
width = memblock dword(1,0)
rem divide by 2 because the real world is twice as large as the image dimensions
x = x/2
y = y/2
x1 = x-radius
y1 = y-radius
x2 = x+radius
y2 = y+radius
r2 = radius*radius
for i = x1 to x2
for j = y1 to y2
if boundaryCheck(i,j) = 1
pos = ((j-1)*width + i)*4 + 12
rem if this point is within the radius
if (x-i)^2 + (y-j)^2 <= r2
rem set alpha to 0 (invisible)
`write memblock dword 1, pos, rgb(255,0,0)
write memblock byte 1, pos+3,0
else
rem alpha is opaque (solid)
`write memblock dword 1, pos, 0
rem write memblock byte 1, pos+3,0
endif
endif
next j
next i
make image from memblock 1, 1
texture object 1, 1
endfunction
rem make sure coordinates are within the image
function boundaryCheck(x,y)
width = memblock dword(1,0)
height = memblock dword(1,4)
if x > 0 and x <= width and y > 0 and y <= height then exitfunction 1
endfunction 0
rem build initial image from memblock
_build_image:
size = maxx*maxy*4 + 12
make memblock 1, size
write memblock dword 1, 0, maxx
write memblock dword 1, 4, maxy
write memblock dword 1, 8, 32
for p = 12 to size-4 step 4
`write memblock dword 1, p, 0
write memblock byte 1, p+3, 255
next p
make image from memblock 1, 1
texture object 1, 1
RETURN