maze

Blitz3D Forums/Blitz3D Beginners Area/maze

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hey, create a cube with say an alpha of 0, the check for collisions between it. And give the camera a collision type and raduis :D

This should do what you need :D

Left and right arrow keys to turn, and up and down arrow keys to move back and forward.

Graphics3D 800,600
SetBuffer BackBuffer()

camera=CreateCamera()
CameraRange camera,0.1,100
PositionEntity camera,0,0,-4
EntityType camera,1

light=createlight()

;------- create the walls and floor and set there entity types for collisions--------

cube=CreateCube()
ScaleEntity cube,5,3,1
PositionEntity cube,0,0,6
EntityAlpha cube,0
EntityType cube,3

ground=CreateCube()
ScaleEntity ground,5,1,10
PositionEntity ground,0,-3,0
EntityColor ground,100,100,250

exit1=CreateCube()
PositionEntity exit1,0,-2.95,8
ScaleEntity exit1,5,1,3

wall1=CreateCube()
PositionEntity wall1,-5,0,0
ScaleEntity wall1,1,3,10
EntityColor wall1,160,160,250
EntityType wall1,2

wall2=CreateCube()
PositionEntity wall2,5,0,0
ScaleEntity wall2,1,3,10
EntityColor wall2,160,160,250
EntityType wall2,2

wall3=CreateCube()
PositionEntity wall3,0,0,-10
ScaleEntity wall3,5,3,1
EntityColor wall3,160,160,250
EntityType wall3,2

Collisions 1,2,2,2; ------ collisions with walls
Collisions 1,3,2,2; ------ collisions with invisble "exit" cube

mode=1; ----- this variable determines which mode the game is in. MODE 1= normal walkabout mode
			; ------ MODE 2= Finished maze and collided with the invisble cube

;------- Main Loop ------
While Not KeyHit(1)
	
	If MouseDown(1) And mode=2 Then; ------if left mouse button is hit then change back to mode 1 and reset camera
		mode=1
		PositionEntity camera,0,0,-4
	End If
		
	If mode=1 Then;---------- check keys if in mode 1 -------
		If KeyDown(200) Then MoveEntity camera,0,0,0.1
		If KeyDown(208) Then MoveEntity camera,0,0,-0.1
		If KeyDown(203) Then TurnEntity camera,0,1,0
		If KeyDown(205) Then TurnEntity camera,0,-1,0

		If EntityCollided(camera,3) Then ;------ check to see if player collides with invisble cube to exit maze.
			mode=2; ------ if player has collided with with invisble cube then set to mode 2
		End If
	End If
	
	UpdateWorld
	RenderWorld
	If mode=1 Then Text 0,0," Stand on the white floor to finish the maze!"
	If mode=2 Then Text 0,0," You've finished the maze!! Press the left mouse button to restart."
	Flip
Wend
End