Hi Tinkergirl.
I have an old project which was similar to this one. If you're still active on the code maybe this will help you.
It's a line of sight algorithm I ripped off an open source game called Tyrant (written in Java). Believe it or not I still don't quite understand how it works, but was able to get it working in my engine. This would be used to prevent the player from seeing through walls in your game.
Like I said I never fully figured it out, so it's not commented at all. A couple notes on the code. I never trusted DBPro booleans (maybe from my 1.3 days or something) so I have a #constant of TRUE/FALSE. Also the +6 (or any math involving 6) is the offset between the top left corner cell of the display, and where the guy stands in the middle. Any math with 11 has to do with the display size. 30 has to do with the map array size.
tileView = 11x11 array with visibility flag
map = 30x30 array of tiles 0 = floor 1 = wall
I've attached a screenshot of how it looks. I was also fooling with a lighting system at the time. Anyways, hope this helps.
function CalcLOS(x as integer, y as integer)
LOS_DETAIL as integer
local tx as integer
local ty as integer
local px as integer
local py as integer
local c as integer
local c1 as integer
local c2 as integer
local c3 as integer
local c4 as integer
local l as integer
local d as integer
local r as integer
tx = 0
ty = 0
px = 0
py = 0
c = 0
LOS_DETAIL = 26
r = 7
tileView(6,6).visible = TRUE
for l = -LOS_DETAIL to LOS_DETAIL
c1 = 1
c2 = 1
c3 = 1
c4 = 1
for d = 1 to r-1
if ((d*d+((d*l)/LOS_DETAIL)*((d*l)/LOS_DETAIL))>(r*r))
c1 = 0
c2 = 0
c3 = 0
c4 = 0
endif
if (c1 = 1)
tx = x + d
ty = (LOS_DETAIL*y+l*d+LOS_DETAIL/2)/LOS_DETAIL;
if InRange(tx,1,30) = TRUE and InRange(ty,1,30) = TRUE
if InRange(tx-x+6,1,11) = TRUE and InRange(ty-y+6,1,11) = TRUE
tileView(tx-x+6,ty-y+6).visible = TRUE
endif
if not (map(tx,ty) = 0)
c1 = 0
endif
endif
endif
if (c2 = 1)
tx = x - d
ty = (LOS_DETAIL*y+l*d+LOS_DETAIL/2)/LOS_DETAIL
if InRange(tx,1,30) = TRUE and InRange(ty,1,30) = TRUE
if InRange(tx-x+6,1,11) = TRUE and InRange(ty-y+6,1,11) = TRUE
tileView(tx-x+6,ty-y+6).visible = TRUE
endif
if not (map(tx,ty) = 0)
c2 = 0
endif
endif
endif
if (c3 = 1)
ty = y + d
tx = (LOS_DETAIL*x+l*d+LOS_DETAIL/2)/LOS_DETAIL
if InRange(tx,1,30) = TRUE and InRange(ty,1,30) = TRUE
if InRange(tx-x+6,1,11) = TRUE and InRange(ty-y+6,1,11) = TRUE
tileView(tx-x+6,ty-y+6).visible = TRUE
endif
if not (map(tx,ty) = 0)
c3 = 0
endif
endif
endif
if (c4 = 1)
ty = y - d
tx = (LOS_DETAIL*x+l*d+LOS_DETAIL/2)/LOS_DETAIL
if InRange(tx,1,30) = TRUE and InRange(ty,1,30) = TRUE
if InRange(tx-x+6,1,11) = TRUE and InRange(ty-y+6,1,11) = TRUE
tileView(tx-x+6,ty-y+6).visible = TRUE
endif
if not (map(tx,ty) = 0)
c4 = 0
endif
endif
endif
next d
next l
endfunction
function InRange(num as integer, min as integer, max as integer)
if (num < min) or (num > max) then exitfunction FALSE
endfunction TRUE
I'm not a real programmer but I play one with DBPro!