maze

Blitz3D Forums/Blitz3D Beginners Area/maze

patisawesome(Posted 2003) [#1]
I'm making a maze game, and I can't make it say,"You win!"
every time the player reaches the finish.
-me


Apollonius(Posted 2003) [#2]
I doubt anyone will answer if you don't post some code my friend, and prolly tell us exactly what you want to do..


patisawesome(Posted 2003) [#3]
I'm trying to make a finish to my maze game,but it's not doing anything. Here's my code:
Include "start.bb"

Const TYPE_COL=1,TYPE_MAZE=10,TYPE_WATER=11,TYPE_B=10

Collisions TYPE_COL,TYPE_MAZE,2,2
Collisions TYPE_COL,TYPE_B,2,2

cam=CreateCamera()
PositionEntity cam,0,4,0
EntityType cam,TYPE_COL
CameraRange cam,1,45000

maze=LoadMesh("maze1.x")
EntityType maze,TYPE_MAZE
ScaleEntity maze,1.5,1.1,1.5

b=LoadMesh("b1.x")
EntityType b,TYPE_B
ScaleEntity b,1.5,1.1,1.5
PositionEntity b,0,-2,0
EntityAlpha b,0

water=LoadMesh("water1.x")
EntityType water,TYPE_water
PositionEntity water,0,-1.5,0
EntityAlpha water,0.5
ScaleEntity water,1.5,1.1,1.5

sky=CreateCube()
ScaleEntity sky,-1000,-1000,-1000
EntityColor sky,0,255,255

l=CreateLight()
LightColor l,255,255,255

l=CreateLight()
LightColor l,255,255,255
TurnEntity l,45,45,0

l=CreateLight()
LightColor l,255,255,255
TurnEntity l,90,90,0

l=CreateLight()
LightColor l,255,255,255
TurnEntity l,135,135,0

l=CreateLight()
LightColor l,255,255,255
TurnEntity l,180,0,180

While Not KeyHit(1)

If KeyDown(200)
MoveEntity cam,0,0,0.2
EndIf

If KeyDown(208)
MoveEntity cam,0,0,-0.2
EndIf

If KeyHit(203)
TurnEntity cam,0,45,0
EndIf

If KeyHit(205)
TurnEntity cam,0,-45,0
EndIf

If Not EntityCollided(maze,cam)
MoveEntity cam,0,-0.08,0
EndIf

UpdateWorld
RenderWorld
Flip
Wend
End


Floyd(Posted 2003) [#4]
It's hard to give a specific answer to this.

You need some way to recognize when the maze is solved.
Collisions are already working, so perhaps you could have a special object
which marks the end of the maze.

When the player collides with this the maze has been solved.


patisawesome(Posted 2003) [#5]
I can't get that to work, can you please give me an example?
-me


Ross C(Posted 2003) [#6]
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



patisawesome(Posted 2003) [#7]
It doesn't seem to detect the collision. Thanks for all the help.
-me


Perturbatio(Posted 2003) [#8]
Curious, it works fine for me. (Ross's code that is).

If you are talking about your own code, have you made sure to set the entity types correctly and set up the collisions correctly also.


patisawesome(Posted 2003) [#9]
I got it to work!, but now I can't get the finish in the correct spot.
-me

Edit:
Can somebody help me?


patisawesome(Posted 2003) [#10]
I got it to work!
Here it is:

Include "start.bb"

Const TYPE_MAZE=10,TYPE_B=10,t1=10

Collisions 2,1,2,2

cam=CreateCamera()
CameraRange cam,0.1,45000
PositionEntity cam,7,5,8
EntityType cam,2

maze=LoadMesh("maze2.x")
ScaleEntity maze,1.5,1.1,1.5
EntityType maze,type_maze

finish=CreateCube()
PositionEntity finish,15,5,-77
ScaleEntity finish,5,5,5
EntityAlpha finish,0
EntityType finish,1

b=LoadMesh("b1.x")
ScaleEntity b,1.5,1.1,1.5
EntityAlpha b,0
PositionEntity b,-2,-1,0
EntityType b,type_b

water=LoadMesh("water1.x")
PositionEntity water,-1.5,-1.5,0
EntityAlpha water,0.5
ScaleEntity water,1.5,1.1,1.5

sky=CreateSphere()
ScaleEntity sky,-1000,-1000,-1000
EntityColor sky,20,10,30

l=CreateLight()
LightRange l,45
TurnEntity l,45,45,0
LightColor l,90,90,90

While Not KeyHit(1)

If EntityCollided(cam,1)

EntityAlpha maze,0
EntityAlpha water,0

blank=CopyEntity(maze)
EntityColor blank,0,0,0

Print "You Win!"
Delay 1000

MoveEntity cam,0,-100000000,0

EntityType cam,3

Delay 1000

End

EndIf

If Not EntityCollided(cam,1)

Collisions 2,TYPE_MAZE,2,2
Collisions 2,TYPE_B,2,2

MoveEntity cam,0,-0.1,0

If KeyDown(200)
MoveEntity cam,0,0,0.2
EndIf

If KeyDown(208)
MoveEntity cam,0,0,-0.2
EndIf

If KeyHit(203)
TurnEntity cam,0,45,0
EndIf

If KeyHit(205)
TurnEntity cam,0,-45,0
EndIf
EndIf


UpdateWorld
RenderWorld
Flip
Wend
End


Have fun! Thanks for the help!
-me