Raycaster?

BlitzPlus Forums/BlitzPlus Programming/Raycaster?

I want to make a simple raycasted game akin to Wolfenstein or Blake Stone. I want to make it with walls, floors and cielings, but that's about as complicated as it needs to be. Anyone know of any raycasting engines/source code for Blitz?

Any idea how do program weapons, enemies, powerups, etc?

Knowing that elsewhere you were asking for tutors: get Blitz3d or Max+3dmod, and use the 3d engine to build your levels. Or dunno, game builders perhaps?

There's little point in trying games/engines/algorithms when you're not up to it, and I doubt someone would be able to explain those things to you if at the same time you're asking for tutors. Blitz isn't a game language, it's a normal procedural BASIC'esque programming language with a gfx-lib aimed for easy game creating, but still you need to code every bit yourself. This is the primary thing that's often misunderstood, and I've seen this *so* many times in the past years..
Of course, with training you can get everywhere you want, but it's just that: training, small steps at a time and don't rush it. Wolf3d sounds a bit like rushing to me, tbh. :P

I guess you're right. I'll practice with B+ an do it myself :)

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.

How would you do that and make a cube instead?