Collision Jousting

Blitz3D Forums/Blitz3D Beginners Area/Collision Jousting

Hi
I'm trying to make a basic jousting game.
However I'm having some problem with the collision.
Thanks for your time.




Graphics3D 800,600

Const CUBE_COL=1
Const SPHERE_COL=2

SetBuffer BackBuffer()

camera=CreateCamera()
CameraViewport camera,0,0,800,600
PositionEntity camera,0,0,-5

light=CreateLight()

cube=CreateCube()
PositionEntity cube,-5,0,5
EntityColor cube,70,80,190
EntityType cube,CUBE_COL

sphere=CreateSphere(12)
PositionEntity sphere,5,0,5
EntityColor sphere,170,80,90
EntityType sphere,SPHERE_COL

Collisions SPHERE_COL,CUBE_COL,3,1
Collisions CUBE_COL,SPHERE_COL,3,1

While Not KeyHit(1)

If KeyDown(30) MoveEntity sphere,-0.02,0,0

If KeyDown(31) MoveEntity Cube,0.02,0,0

UpdateWorld
RenderWorld

If EntityCollided(sphere,1) Then
Text 370,60,"sphere Collided !"
EndIf

If EntityCollided(cube,2) Then
Text 370,80,"Cube Collided !"
EndIf

Text 300,40,"Use (A) and (S) keys to move."
Text 335,500," Collision Demo "
Flip

Wend

End

Hmmm... I'll check this out.

EDIT: Wait... It works perfectly for me. What exactly do you want it to do?

Wow that was quick.
Thanks alot.

Thanks a lot for what? All I did was tell you it was working perfectly.
Oh, and nice homepage ;)

What hapening for me is that if you move the sphere
the text comes up for both the cube and the sphere.
but if you move cube the text for just the cube prints to screen.
I want it so that only one will print to the screen.
not both.

Your posting faster then I can write lol

What hapening for me is that if you move the sphere
the text comes up for both the cube and the sphere.


Right... I noticed That...
Your posting faster then I can write lol


Yeah... I'm surprised I can type this fast. I can't seem to get my hands in the right position though...

I was wondering do I need to make some kind of timer?

I have no idea.

You could use ResetEntity:
Graphics3D 800,600,0,2

Const CUBE_COL=1
Const SPHERE_COL=2

SetBuffer BackBuffer()

camera=CreateCamera()
CameraViewport camera,0,0,800,600
PositionEntity camera,0,0,-5

light=CreateLight()

cube=CreateCube()
PositionEntity cube,-5,0,5
EntityColor cube,70,80,190
EntityType cube,1

sphere=CreateSphere(12)
PositionEntity sphere,5,0,5
EntityColor sphere,170,80,90
EntityType sphere,1

Collisions 1,1,3,1

While Not KeyHit(1)

If KeyDown(30) MoveEntity sphere,-0.2,0,0

If KeyDown(31) MoveEntity Cube,0.2,0,0

UpdateWorld
RenderWorld

If EntityCollided(sphere,1) Then
	For i = 1 To CountCollisions(sphere)
		ent = CollisionEntity(sphere, i)
		If GetEntityType(ent) = 1 Then
			Text 370,60,"sphere Collided !"
			ResetEntity ent
		End If
	Next
EndIf

If EntityCollided(cube,1) Then
	For i = 1 To CountCollisions(cube)
		ent = CollisionEntity(cube, i)
		If GetEntityType(ent) = 1 Then
			Text 370,60,"cube Collided !"
			ResetEntity ent
		End If
	Next
EndIf

Text 300,40,"Use (A) and (S) keys to move."
Text 335,500," Collision Demo "
Flip

Wend

End


Thanks for all your help. I'll give it a try.
Sorry it took so long for me
to reply.