Collisions
Blitz3D Forums/Blitz3D Beginners Area/Collisions
| ||
I'm making a tank game but the collisions wont work right heres the code: Graphics3D 1024,768 SetBuffer BackBuffer() type_player=1 type_sceenery=2 camera=CreateCamera() PositionEntity camera,0,-4,0 light=CreateLight() terrain=LoadTerrain ( "snowball.jpg" ) ScaleEntity terrain,5,100,5 PositionEntity terrain,-500,-10,-500 tex=LoadTexture( "grass.jpg" ) ScaleTexture tex, 5,5 EntityTexture terrain,tex EntityType terrain,type_sceenery water=CreatePlane() PositionEntity water, -500,-15,-500 watertexture=LoadTexture ("water.jpg") ScaleTexture watertexture,15,15 EntityTexture water, watertexture maxbull = 100 Dim bullet(maxbull) For i=0 To maxbull bullet(i)=LoadMesh ("bullet.3ds") EntityColor bullet(i), 100,100,100 EntityType bullet(i), type_bullet Next tank=LoadMesh ("btadpole.3ds") PositionEntity tank,0,-5,8 ScaleEntity tank,0.01,0.01,0.01 EntityColor tank,0,100,0 RotateEntity tank,0,180,0 EntityType tank,type_player EntityRadius tank,0.5 Collisions type_player,type_sceenery,1,2 While Not KeyDown( 1 ) If KeyHit (57) And reload = 0 PlaySound phaser PositionEntity bullet(t) ,EntityX(camera,1),EntityY(camera,1),EntityZ(camera,1) RotateEntity bullet(t),EntityPitch#(camera,1),EntityYaw#(camera,1),EntityRoll#(camera,1) EntityColor bullet(t),0,0,255 t=t+1 EndIf For q = 0 To maxbull MoveEntity bullet(q), 0,-0.02,2 If CountCollisions (bullet(q)) crash=CollisionEntity (bullet(q),1) HideEntity crash score#=score#+1 PlaySound explosion EndIf Next bulletcount=100-t If t=100 Then reload=1 EndIf If KeyDown (19) = True Then t=0 reload=0 EndIf PositionEntity camera, EntityX (tank),EntityY (tank)+5,EntityZ (tank)+3 If KeyDown( 205 )=True Then TurnEntity tank,0,-1,0 If KeyDown( 203 )=True Then TurnEntity tank,0,1,0 If KeyDown( 208 )=True Then MoveEntity tank,0,0,1 If KeyDown( 200 )=True Then MoveEntity tank,0,0,-1 If KeyDown( 205 )=True Then TurnEntity camera,0,-1,0 If KeyDown( 203 )=True Then TurnEntity camera,0,1,0 UpdateWorld RenderWorld Flip Wend End If any one could help that would be great!!! |
| ||
You could better use the code or codebox tag instead of the underline tag. I'm not sure what you want to collisions to do, but I think it is better to use: Collisions 1, 2, 2, 4 instead (for the tank vs terrain). "type_bullet" is not defined, and therefore zero. Also, no collisions are set up for bullets-to-something-else, and there is not something else to hit. |
| ||
the last parameter in Collisions only goes to 3 |
| ||
Define "won't work right"? Just an observation, you should be using instances for your bullets ...e.g. maxbull = 100 Dim bullet(maxbull) bullmesh = LoadMesh("bullet.3ds") EntityColor bullmesh, 100,100,100 EntityType bullmesh, type_bullet HideEntity bullmesh For i=0 To maxbull bullet(i) = CopyEntity( bullmesh ) Next |