i have the line height and i can draw it:
'a' is my image class instance.
now i want get the image line:
the image line is drawed... but incorrectly :(
heres the result: https://imgur.com/W6NbjQp
Code:
a.drawline(x0,y0,x1,y1) A.DrawLine 475 + 50 + RayCounts, 200 / 2 - RayHeight / 2, 475 + 50 + RayCounts, 200 / 2 + RayHeight / 2
now i want get the image line:
Code:
If VertDist < HorizDist Then
' Draw the vertical ray:
A.DrawLine Fix(Player.PosX), Fix(Player.PosY), Fix(VertX), Fix(VertY)
WallDistance = VertDist
'getting the image line position:
GridX = VertX Mod ObjectSize
GridY = VertY Mod ObjectSize
Else
' Draw the horizontal ray:
A.DrawLine Fix(Player.PosX), Fix(Player.PosY), Fix(HorizX), Fix(HorizY)
WallDistance = HorizDist
'getting the image line position:
GridX = HorizX Mod ObjectSize
GridY = HorizY Mod ObjectSize
End If
'Debug.Print GridX & " " & GridY
WallDistance = WallDistance * Cos(RayRadians - Player.Radians) 'avoiding the Fish Effect
RayHeight = (ObjectSize / WallDistance) * 200 ' is the height screen\
'a.drawline(x0,y0,x1,y1) A.DrawLine 475 + 50 + RayCounts, 200 / 2 - RayHeight / 2, 475 + 50 + RayCounts, 200 / 2 + RayHeight / 2
If (GridX = 0) Then
StretchBlt A.MemoryHDC, 475 + 50 + RayCounts, 200 / 2 - RayHeight / 2, 475 + 50 + RayCounts, 200 / 2 + RayHeight / 2, picWall1.hdc, 0, GridY, 1, picWall1.Height, SRCCOPY
Else
StretchBlt A.MemoryHDC, 475 + 50 + RayCounts, 200 / 2 - RayHeight / 2, 475 + 50 + RayCounts, 200 / 2 + RayHeight / 2, picWall1.hdc, GridX, 0, picWall1.Width, 1, SRCCOPY
End If
heres the result: https://imgur.com/W6NbjQp