Graphics3D 640,480,32,2 SetBuffer BackBuffer() WBuffer 1 HidePointer Type Player Field iD, name$, mesh[10], score End Type Const GRAVITY#=-.01 Global camera=CreateCamera() EntityType camera,TCam light=CreateLight() Const BODY=1,WHEEL=2,SCENE=3,bul=4,SkyYY=5,TCam=6 Collisions BODY,SCENE,2,3 Collisions WHEEL,SCENE,2,3 Collisions bul,scene,2,3 AppTitle"Play the car gameS" Global car=LoadMesh("carr.3ds") EntityRadius car,.6 carty$="jeep" PositionEntity car,0,20,0 ScaleEntity car,0.02,0.02,0.02 EntityType car,BODY EntityShininess car,1 shadow=LoadSprite("shadow.bmp",4) ScaleSprite shadow,1,1 RotateEntity shadow,90,0,0 SpriteViewMode shadow,4 bulle=CreateSphere(2,car) ScaleEntity bulle,8,8,16 EntityType bulle,bul EntityAlpha bulle,0 skyt=LoadTexture("sky.bmp",2) sphere=CreateSphere(8) PositionEntity sphere,250,0,-300 ScaleEntity sphere,550,550,550 FlipMesh sphere EntityAlpha sphere,1 EntityType sphere,SkyYY EntityTexture sphere,skyt Global terrain=LoadTerrain("ground t.bmp") ScaleEntity terrain,3,28,3 PositionEntity terrain,-180,0,-727 EntityType terrain,SCENE TerrainShading terrain,True Collisions TCam,SCENE,2,2 Type flar Field flare,K# End Type Collisions bul,SkyYY,2,2 jeept=LoadTexture("jeept.png") boom=LoadSprite("boom2.bmp") EntityAlpha boom,0 SeedRnd(MilliSecs()) If carty$="jeep" EntityTexture car,jeept EndIf groundt=LoadTexture("ground tt.bmp") ScaleTexture groundt,TerrainSize(terrain),TerrainSize(terrain) grass=LoadTexture("grass.bmp") TextureBlend grass,3 EntityTexture terrain,grass,0,0 EntityTexture terrain,groundt,0,1 Global wheels[4] cnt=1 For z#=300 To -300 Step -600 For x#=-200 To 200 Step 400 wheels[cnt]=CreateSphere( 8,car ) EntityAlpha wheels[cnt],0 ScaleEntity wheels[cnt],5,5,5 EntityRadius wheels[cnt],.6 PositionEntity wheels[cnt],x,0,z EntityType wheels[cnt],WHEEL cnt=cnt+1 Next Next Type tt Field nboom,A#,B# End Type KKW=1 target=CreatePivot(car) PositionEntity target,0,50,-170 CameraClsColor camera,0,0,255 Type bu Field bull,litt,sf End Type speed#=0 x_vel#=0:prev_x#=EntityX( car ) y_vel#=0:prev_y#=EntityY( car ) z_vel#=0:prev_z#=EntityZ( car ) Type lit Field light End Type Collisions Body,SkyYY,2,2 .there send=MilliSecs() While level=0 Cls If KeyDown(29) And TI=0 bullet.bu=New bu time=MilliSecs() TI=1 bullet\bull=CopyEntity(bulle,car) PositionEntity bullet\bull,0,21,27 EntityParent bullet\bull,0 EntityAlpha bullet\bull,1 bullet\litt=CreateLight(3,bullet\bull) EndIf If KeyDown(1) End EndIf For bullet.bu = Each bu MoveEntity bullet\bull,0,0,1.5 fl.flar=New flar fl\flare=CopyEntity(boom,bullet\bull) EntityParent fl\flare,0 fl\K=0 ScaleSprite fl\flare,20,20 EntityAlpha fl\flare,1 fl\K#=1 If CountCollisions(bullet\bull)>0 xxxx#=EntityX(bullet\bull,True) yyyy#=EntityY(bullet\bull,True) zzzz#=EntityZ(bullet\bull,True) FreeEntity fl\flare Delete fl FreeEntity bullet\bull Delete bullet dt.tt=New tt dt\nboom=CopyEntity(boom) ScaleSprite dt\nboom,10,10 dt\B#=1 PositionEntity dt\nboom,xxxx#,yyyy#,zzzz# dt\A#=1 EndIf Next For fl.flar = Each flar ScaleSprite fl\flare,fl\K#,fl\K# If fl\K#>0 fl\K#=fl\K#-0.1 Else FreeEntity fl\flare Delete fl EndIf Next If KeyDown(17) And KeyDown(23) And KeyHit(49) If KKW=1 waa=0 KKW=0 EndIf waa=-waa If waa=0 Then waa=1 If waa=-1 Then waa=0 EndIf WireFrame waa For dt.tt = Each tt If dt\A#>0 dt\A#=dt\A#-0.1 dt\B#=dt\B#+10 RotateSprite dt\nboom,B# EndIf EntityAlpha dt\nboom,dt\A# Next If MilliSecs()>time + 150 TI=0 EndIf zx#=(EntityX( wheels[2],True )+EntityX( wheels[4],True ))/2 zx=zx-(EntityX( wheels[1],True )+EntityX( wheels[3],True ))/2 zy#=(EntityY( wheels[2],True )+EntityY( wheels[4],True ))/2 zy=zy-(EntityY( wheels[1],True )+EntityY( wheels[3],True ))/2 zz#=(EntityZ( wheels[2],True )+EntityZ( wheels[4],True ))/2 zz=zz-(EntityZ( wheels[1],True )+EntityZ( wheels[3],True ))/2 AlignToVector car,zx,zy,zz,1 zx#=(EntityX( wheels[1],True )+EntityX( wheels[2],True ))/2 zx=zx-(EntityX( wheels[3],True )+EntityX( wheels[4],True ))/2 zy#=(EntityY( wheels[1],True )+EntityY( wheels[2],True ))/2 zy=zy-(EntityY( wheels[3],True )+EntityY( wheels[4],True ))/2 zz#=(EntityZ( wheels[1],True )+EntityZ( wheels[2],True ))/2 zz=zz-(EntityZ( wheels[3],True )+EntityZ( wheels[4],True ))/2 AlignToVector car,zx,zy,zz,3 cx#=EntityX( car ):x_vel=cx-prev_x:prev_x=cx cy#=EntityY( car ):y_vel=cy-prev_y:prev_y=cy cz#=EntityZ( car ):z_vel=cz-prev_z:prev_z=cz cnt=1 For z=25 To -25 Step -50 For x=-30 To 30 Step 60 PositionEntity wheels[cnt],x,-10,z cnt=cnt+1 Next Next If EntityCollided( car,SCENE ) G=0 If KeyDown(203) TurnEntity car,0,speed*5,0 G=1 If KeyDown(205) TurnEntity car,0,-speed*5,0 G=2 If KeyDown(200) speed=speed+.02 If speed>.7 speed=.7 Else If KeyDown(208) speed=speed-.02 If speed<-.5 speed=-.5 Else speed=speed*.9 EndIf MoveEntity car,0,0,speed TranslateEntity car,0,GRAVITY,0 Else If G=1 TurnEntity car,0,speed*5,0 ElseIf G=2 TurnEntity car,0,-speed*5,0 EndIf TranslateEntity car,x_vel,y_vel+GRAVITY,z_vel EndIf PositionEntity shadow,EntityX#(car,True),TerrainY#(terrain,EntityX#(car,True),EntityY(car,True),EntityZ#(car,True))+.1,EntityZ#(car,True) If speed>=0 dx#=EntityX( target,True )-EntityX( camera ) dy#=EntityY( target,True )-EntityY( camera ) dz#=EntityZ( target,True )-EntityZ( camera ) TranslateEntity camera,dx*.3,dy*.3,dz*.3 EndIf PointEntity camera,car RotateEntity shadow,EntityPitch#(car,True)+90,0,0 UpdateWorld RenderWorld If KeyHit(25) FlushKeys() While Not KeyHit(25) If KeyDown(1) End EndIf If KeyHit(2) FlushKeys() me$=Input$("what would you like it to be called? ") SaveBuffer(BackBuffer(),me$+".bmp") EndIf Flip Wend EndIf Color 0,0,0 Flip Wend End
I used a 256 by 256 terrain and just a bunch of dots for the grass why is it going so slow!
thanks