Well, there are some tutorials online about raycasters. I found this one:
http://www.permadi.com/tutorial/raycast/I wrote this code, if you run it, you'll see a rotating shape.
Then, uncomment the commands in STEP 2 and run it again.
After that, uncomment the commands in STEP 3 and run.
;point-type stores points
;by their angle and radius
Type Point
Field ang#, rad#
End Type
Graphics 800, 600, 0, 2
SetBuffer BackBuffer()
;create 17 walls
For i = 0 To 16
;this is used to generate the cross-like shape of the walls, not
;important for this program
s = ((i Mod 4) / 2) * 100 + 100
;create some points, the coordinates should be in range (-400,-300) to (400,300)
;these can be whatever you like
px# = Cos(i * 360 / 16) * s
py# = Sin(i * 360 / 16) * s
;convert x, y to (angle, radius)
;and store as a 'Point'
p.Point = New Point
p\ang = ATan2(py, px)
p\rad = Sqr(px*px + py*py)
Next
;set origin at 400,300
;(400,300) = (0,0)
Origin 400, 300
;scaling
sc# = 300
Repeat
Cls
;offset for turn-around
oa = oa + 1
;draw lines from each point
For p.Point = Each Point
If p <> Last Point Then
o.Point = After p
;rotate points
px# = Cos(oa + p\ang) * p\rad
py# = 100
pz# = Sin(oa + p\ang) * p\rad
ox# = Cos(oa + o\ang) * o\rad
oy# = 100
oz# = Sin(oa + o\ang) * o\rad
;------------------------------------------------------------------------------------
; STEP 1
;------------------------------------------------------------------------------------
;original line
Line px, pz, ox, oz
;------------------------------------------------------------------------------------
; STEP 2
;------------------------------------------------------------------------------------
;;apply depth (basically x = x / z : y = y / z)
;x1# = px * sc / (pz# + 300)
;y1# = py * sc / (pz# + 300)
;x2# = ox * sc / (oz# + 300)
;y2# = oy * sc / (oz# + 300)
;;draw line
;Line x1, y1, x2, y2
;------------------------------------------------------------------------------------
; STEP 3
;------------------------------------------------------------------------------------
;;draw counterpart (mirror line on y-axis)
;Line x1, - y1, x2, - y2
;;draw connecting lines (step 4)
;Line x1, y1, x1, -y1
;Line x2, y2, x2, -y2
End If
Next
Flip
Until KeyHit(1)
End
Not sure if that is the way to make a raycaster, but from this, I built a sort-of wolfenstein-like program under dos.