Ok copy and paste this. I added a collision code.
Graphics3D 1024,768,32
Const PLANE1=1,SCENE=2,TERRAIN=3
Global health=100
Global status$
Collisions PLANE1,SCENE,2,3
Collisions PLANE1,TERRAIN,2,3
HidePointer
palm1=LoadMesh("palm1.3ds")
;palm1 = CreateCylinder()
EntityType palm1,SCENE
HideEntity palm1
water=CreatePlane()
PositionEntity water,0,-100,0
;EntityColor water, 0,0,255
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")
;plane = CreateCube()
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
;EntityRadius plane, 1,1
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
EntityColor sky, 150,150,150
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,-.01,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
For collision_id = 1 To CountCollisions(plane)
collision_entity = CollisionEntity(plane, collision_id)
If GetEntityType(collision_entity) = TERRAIN
impact_speed# = speed
crash_damage(impact_speed)
End If
Next
;If speed#>2 And EntityCollided(plane,TERRAIN) =1
; status$="SOFT COLLISION"
; health=health-1
;ElseIf speed#>10 And EntityCollided(plane,TERRAIN) =1
; status$="MEDIUM COLLISION"
; health=health-5
;ElseIf speed#>15 And EntityCollided(plane,TERRAIN)=1
; status$="HARD COLLISION"
; health=health-10
;ElseIf speed#>20 And EntityCollided(plane,TERRAIN) =1
; 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
Function crash_damage(impact_speed)
If impact_speed > 2
health = healh -1
status$ = "SOFT COLLISION"
ElseIf impact_speed > 10
health = health - 5
status$ = "MEDIUM COLLISION"
ElseIf impact_speed > 15
health = health - 10
status$ = "HARD COLLISION"
ElseIf impact_speed > 20
health = health - 50
status$ = "DEADLY COLLISION"
End If
End Function