Hi all,
since AppGameKit now supports 3D, I was having a go at converting some old DBPro-code in order to create a maze game (a bit like Cliff Mellangard and Van B's dungeon game, but far less impressive). I'm having trouble with my LOS-function though: the part that calculates which parts of the map are visible to the player and which parts should remain hidden. I've used code
originally posted by Todd Riggins.
My problem is that (my use) of the LOS-function is not very refined: some tiles that should not be visible to the player are displayed, while others that should be, are.. well.. not. I've illustrated the problem by providing two images, besides posting a quickly made test-application. Can someone help me refine the LOS? Any help would be greatly appreciated!

(the line in the indicated circle should not be visible)

(the two while blocks in the circle should be visible)
Here's the part of the code that calculates the LOS (should you not wish to download the program):
`--------------------------------------------------------------------------------------
` Function to calculate the line of sight for the player
`--------------------------------------------------------------------------------------
function CalcLOS(StartX, StartZ, EndX, EndZ)
if StartX = EndX and StartY = EndY then exitfunction 1
// calculate how many steps exist between start- and end-position on X and Z-axis of LOS
DifX = StartX - EndX
DifZ = StartZ - EndZ
// convert the differences to absolute numbers and multiply them
AbsX = ABS(DifX) * Refiner
AbsZ = ABS(DifZ) * Refiner
// set the sign of the axis to be positive by default...
SgnX = 1
SgnZ = 1
// ...but set it to be negative if the difference on the X-axis is less then zero
if DifX < 0 then SgnX = -1
if DifZ < 0 then SgnZ = -1
TmpX = EndX
TmpZ = EndZ
// check to see if either the x- or z-axis is dominant and loops accordingly
if AbsX > AbsZ
Tile = AbsZ - (AbsX / Refiner)
repeat
if Tile >= 0
TmpZ = TmpZ + SgnZ
Tile = Tile - AbsX
endif
TmpX = TmpX + SgnX
Tile = Tile + AbsZ
// exit from function if we are at the player's position
if (TmpX = StartX) and (TmpZ = StartZ)
exitfunction 1
endif
// keep checking until specified location is blocked by an non-transparent object
until MapData[TmpX, TmpZ].Transparent = 0
exitfunction 0
else
Tile = AbsX - (AbsZ / Refiner)
repeat
if Tile >= 0
TmpX = TmpX + SgnX
Tile = Tile - AbsZ
endif
TmpZ = TmpZ + SgnZ
Tile = Tile + AbsX
if (TmpX = StartX) and (TmpZ = StartZ)
exitfunction 1
endif
until MapData[TmpX, TmpZ].Transparent = 0
exitfunction 0
endif
endfunction 0