Been struggling with the following (I think I found the idea on here originally)
Want to always have a single value on each line (you can see where the value is anded) but it's not always a straight line. If you uncomment the ' camX += 0.1 line, you can see it flickering when moving.
Been struggling with this for a bit, so would be very happy if someone can solve this problem for me!!
cheers
' Floor Casting
const XRES = 640
const YRES = 480
'const xres = 320
'const yres = 240
#include once "tinyptc.bi"
if (ptc_open("FLOOR CASTING", 640, 480) = 0) then end -1
dim shared as integer buffer(XRES*YRES)
Dim Shared as single u, v, w, camX, camY
Declare Sub floor()
while (inkey$ = "")
floor()
ptc_update@buffer(0)
ERASE BUFFER
Wend
ptc_close
end 0
Sub floor()
dim as integer c, b, r
'camY += 1
' camX += 1 'xres*sin(camY*3.14159/180)
' camX += 0.1
b = 150*XRES
For y = 50 to 200-1
w = -240 / y
v = XRES*w - camY
u = -320*w + camX
for x = 1 To XRES-1
r=(u And 255)
Select Case r
Case 0
buffer(b+x) = rgb(255,0,0)
Case Else
buffer(b+x) = rgb(0,0,0)
End Select
' Else
' buffer(b+x) = rgb(0,0,0)
'buffer(b+x) = rgb(u And 255,v And 255,0)
u=u+w
Next x
b=b+XRES
Next y
End Sub