1
Programming / Re: Need help to implement a Line-of-Sight algorithm for a roguelike in VB6
« on: August 06, 2008, 08:42:52 AM »
Hmmm...it seems like I need to study more about the order of what does what in this algorithm.
In the meanwhile, I toyed with a Recursive Shadowcasting FOV, found here:
http://roguebasin.roguelikedevelopment.org/index.php?title=FOV_using_recursive_shadowcasting_-_improved
which works alright, but has 1 major flaw which I don't know how to fix yet:
As you can see in the attachment (only the 1st octant is processed), behind a single obstruction, at some specific spots, the "shadow" line is not consistent. So behind eg. a pillar, other tiles are visible while others are not. This happens especially when the obstruction tile approaches the y-axis. The code (for the 1st octant only) is:
Are there any workarounds for these "blind spots" behind single obstructions?
Or, an even better question: Is this "flaw" important? How many roguelikes have been out there having these kind of issues and yet being fun as hell?
In the meanwhile, I toyed with a Recursive Shadowcasting FOV, found here:
http://roguebasin.roguelikedevelopment.org/index.php?title=FOV_using_recursive_shadowcasting_-_improved
which works alright, but has 1 major flaw which I don't know how to fix yet:
As you can see in the attachment (only the 1st octant is processed), behind a single obstruction, at some specific spots, the "shadow" line is not consistent. So behind eg. a pillar, other tiles are visible while others are not. This happens especially when the obstruction tile approaches the y-axis. The code (for the 1st octant only) is:
Code: [Select]
Public Sub RecursiveVisibility(px As Single, py As Single, oct As Long, depth As Long, slopeA As Single, slopeB As Single)
Dim mw As Long
mw = range ^ 2
Dim x As Single, y As Single
Select Case oct
Case 1:
y = py - depth
x = Int(px - slopeA * depth)
Do While GetSlopeStd(x, y, px, py) >= slopeB
If GetVisDistance(x, y, px, py) <= mw Then
If room(x, y) = 1 Then
If room(x - 1, y) = 0 Then RecursiveVisibility px, py, 1, depth + 1, slopeA, GetSlopeStd(x - 0.5, y + 0.5, px, py)
Else
If room(x - 1, y) = 1 Then slopeA = GetSlopeStd(x - 0.5, y - 0.5, px, py)
End If
vismap(x, y) = 1
End If
x = x + 1
Loop
x = x - 1
End Select
If depth < range And room(x, y) = 0 Then
RecursiveVisibility startx, starty, oct, depth + 1, slopeA, slopeB
End If
End Sub
Are there any workarounds for these "blind spots" behind single obstructions?
Or, an even better question: Is this "flaw" important? How many roguelikes have been out there having these kind of issues and yet being fun as hell?