Cant get this to work

Blitz3D Forums/Blitz3D Programming/Cant get this to work

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.

ok, here is my whole code, don't make fun of it, can someone try to see why the crashes are not detected.

Graphics3D 1280,1024,32

Const PLANE1=1,SCENE=2,TERRAIN=3

health=100

Collisions PLANE1,SCENE,2,3
Collisions PLANE1,TERRAIN,2,3

HidePointer

palm1=LoadMesh("palm1.3ds")
EntityType palm1,SCENE
HideEntity palm1

water=CreatePlane()
PositionEntity water,0,-100,0
texwater=LoadTexture("water.jpg")
EntityTexture water,texwater
ScaleTexture texwater,500,500

;terr=LoadMesh("terrain 1.3ds")
terr=LoadTerrain("terrain.png")
ScaleEntity terr,100,10000,100
PositionEntity terr,0,-2700,0
texterr=LoadTexture( "stone.jpg" )
ScaleTexture Texterr,5,5
EntityTexture terr,Texterr
EntityType terr,TERRAIN

ScaleEntity palm1, 15,15,15      ;you don't need to specify these each Loop
EntityType palm1,SCENE           ;copyentity() copies entity commands as well as the mesh

For a = 1 To 3000

palm1=CopyEntity(palm1) 
bx# = Rnd (2000,50000)
by# = 0           ;this number actually doesn't matter
bz# = Rnd (2000,50000)
terrain_height# = TerrainY(terr, bx,by,bz)
PositionEntity palm1, bx,terrain_height, bz 

Next

plane=LoadMesh("befighter3.3ds")
ScaleMesh plane,0.1,0.1,-0.1
;RotateEntity plane,0,180,0
;FitMesh plane,-0.5,-1,-3,3,2,6
;PositionEntity plane,7000,2000,7000
PositionEntity plane,1,10,1
EntityType plane,PLANE1
FlipMesh plane

light=CreateLight()
TurnEntity light,45,45,0

target=CreatePivot( plane )
PositionEntity target,0,5,-12

tex2=LoadTexture("dusk.jpg")
sky=CreateSphere()
EntityTexture sky,tex2
ScaleEntity sky,5000,5000,5000
FlipMesh sky
EntityFX sky,8

;Global sky = create_skybox()
;PositionEntity sky,0,35,0

camera=CreateCamera()
CameraFogMode camera,1
CameraFogRange camera,0,3000
CameraRange camera,1,6000
CameraFogColor camera,222,252,255

While Not KeyHit(1)

	;If EntityCollided(palm1,TERRAIN)=False Then MoveEntity palm1,0,-10,0

PositionEntity sky,EntityX(plane),EntityY(plane),EntityZ(plane)
;TurnEntity sky,0,0.03,0

If KeyDown(30) Then speedgoal#=speedgoal#+.05
If KeyDown(44) Then speedgoal#=speedgoal#-.05

If speed#<speedgoal# And speed#<10 Then speed#=speed#+.01 : gear$="First Gear"
If speed#>speedgoal# And speed#<10 Then speed#=speed#-.01 : gear$="First Gear"

If speed#<speedgoal# And speed#<20 And speed#>10 Then speed#=speed#+.04 : gear$="Second Gear"
If speed#>speedgoal# And speed#<20 And speed#>10 Then speed#=speed#-.04 : gear$="Second Gear"

If speed#<speedgoal# And speed#<30 And speed#>20 Then speed#=speed#+.08 : gear$="Third Gear"
If speed#>speedgoal# And speed#<30 And speed#>20 Then speed#=speed#-.08 : gear$="Thrid Gear"

If speed#<speedgoal# And speed#<50 And speed#>30 Then speed#=speed#+.1 : gear$="Forth Gear"
If speed#>speedgoal# And speed#<50 And speed#>30 Then speed#=speed#-.1 : gear$="Forth Gear"

If speed#>speedgoal# And speed#=50 Then speed#=speed#-.1 : gear$="FULL SPEED"
If speed#=50 Then gear$="FULL SPEED"

If speed#<0 Then speed#=0
If speed#>50 Then speed#=50
If speedgoal#<0 Then speedgoal#=0
If speedgoal#>50 Then speedgoal#=50

If speed<5 Then MoveEntity plane,0,-1,speed#

turnleftspeed#=speed#*.5
turnrightspeed#=speed#*-.5
If turnleftspeed#>5 Then turnleftspeed#=5
If turnrightspeed#<-5 Then turnrightspeed#=-5

If KeyHit(2) Then speedgoal#=50

;If EntityCollided(plane,TERRAIN) Then status$="SOFT COLLISION" : health=health-1 

	;If speed#>2 And EntityCollided(plane,TERRAIN) Then status$="SOFT COLLISION" : health=health-1 
	;If speed#>10 And EntityCollided(plane,TERRAIN) Then status$="MEDIUM COLLISION" : health=health-5
	;If speed#>15 And EntityCollided(plane,TERRAIN) Then status$="HARD COLLISION" : health=health-10
	;If speed#>20 And EntityCollided(plane,TERRAIN) Then status$="DEADLY COLLISION" : health=health-50
	
	If speed#>2 And EntityCollided(plane,TERRAIN) 
   status$="SOFT COLLISION" 
   health=health-1 
ElseIf speed#>10 And EntityCollided(plane,TERRAIN) 
   status$="MEDIUM COLLISION" 
   health=health-5
ElseIf speed#>15 And EntityCollided(plane,TERRAIN) 
   status$="HARD COLLISION" 
   health=health-10
ElseIf speed#>20 And EntityCollided(plane,TERRAIN) 
   status$="DEADLY COLLISION" 
   health=health-50
EndIf

	
	If health<1 Then RuntimeError("YOU DIED!!")

	If KeyDown(203) Then TurnEntity plane,0,0,turnleftspeed#
	If KeyDown(205) Then TurnEntity plane,0,0,turnrightspeed#
	If KeyDown(200) Then TurnEntity plane,1,0,0
	If KeyDown(208) And speed#>0.5 TurnEntity plane,-1,0,0
	MoveEntity plane,0,0,speed#

	dx#=EntityX( target,True )-EntityX( camera )
		dy#=EntityY( target,True )-EntityY( camera )
		dz#=EntityZ( target,True )-EntityZ( camera )
		TranslateEntity camera,dx*.1,dy*.1,dz*.1
		
	PointEntity camera,plane
	
		UpdateWorld
	
	RenderWorld
	Text 10,10,"ACTUAL SPEED = "+speed#
	Text 10,20,"SPEED GOAL = "+speedgoal#
	Text 10,30,""+gear$
	Text 10,50,"LEFT TURN SPEED = "+turnleftspeed#
    Text 10,60,"RIGHT TURN SPEED = "+turnrightspeed#
	Text 500,10,"STATUS = "+status+"     HEALTH = "+health
	Text 500,20,"COORDINATES 
	Text 500,30," X="+EntityX(plane)
	Text 500,40," Y="+EntityY(plane)
	Text 500,50," Z="+EntityZ(plane)
	Flip

Wend

End