If you make use of it a bit of credit would be appreciated after all this doesn't just fall out of my computer and stuff.
I actually rewrote this from scratch and every time I rewrite stuff it's better and better! This is pretty cool actually even though I say so myself!
There's exaggerated drift on the back wheels so you get opposite lock going on which just looks cool. Exaggerated body roll, because it looks cool and Exaggerated steering lock because... well... it looks cool.
Who needs real physics when you can fake it eh!?
And yes... I know it looks like a brick on wheels.
I actually rewrote this from scratch and every time I rewrite stuff it's better and better! This is pretty cool actually even though I say so myself!
There's exaggerated drift on the back wheels so you get opposite lock going on which just looks cool. Exaggerated body roll, because it looks cool and Exaggerated steering lock because... well... it looks cool.
Who needs real physics when you can fake it eh!?
And yes... I know it looks like a brick on wheels.
Graphics3D 1024,768,32,2 camera = CreateCamera() MoveEntity camera,0,30,-10 light = CreateLight():RotateEntity light,45,45,0 ; Build Car F_Axel = CreatePivot() R_Axel = CreatePivot() F_Bumper = CreatePivot() RL_Wheel = CreateWheel(R_Axel) RR_Wheel = CreateWheel(R_Axel) FL_Wheel = CreateWheel(F_Bumper) FR_Wheel = CreateWheel(F_Bumper) Body = CreateCube(R_Axel) EntityColor body,255,50,0 ScaleEntity body,2,1,4 PositionEntity body,0,2,2.5 MoveEntity RL_wheel,-2,0,0 MoveEntity RR_wheel,2,0,0 MoveEntity FL_wheel,-2,0,0 MoveEntity FR_wheel,2,0,0 MoveEntity r_axel,0,0,-5 EntityParent F_Bumper,R_Axel speed# = 0 drift# = 0 steer# = 0 ; Build Ground Ground = CreatePlane() i = CreateImage(64,64) SetBuffer(ImageBuffer(i)) Color 0,0,255:Rect 0,0,32,32:Rect 32,32,32,32 Color 0,100,255:Rect 32,0,32,32:Rect 0,32,32,32 checker = CreateTexture(64,64) CopyRect 0,0,64,64,0,0,ImageBuffer(i),TextureBuffer(checker ) FreeImage i ScaleTexture checker ,50,50 EntityTexture ground,checker PositionEntity ground,0,-1,0 SetBuffer BackBuffer() t=MilliSecs() Repeat ; Steering If KeyDown(205) Then steer = steer + 2 If KeyDown(203) Then steer = steer - 2 steer = steer * .6 ; turn the wheels RotateEntity f_axel,0,EntityYaw(r_axel)-steer,0 RotateEntity FL_Wheel,0,EntityYaw(r_axel,True)-(steer*10),0,True RotateEntity FR_Wheel,0,EntityYaw(r_axel,True)-(steer*10),0,True ; gas If KeyDown(200) Then speed = speed + .2 speed = speed * .94 ; forwards MoveEntity f_axel,0,0,speed PointEntity r_axel,f_axel MoveEntity r_axel,0,0,EntityDistance(r_axel,f_axel)-5 ;5 is the car length ; drift drift = drift + (steer * speed) * -.01 drift = drift * .95 MoveEntity f_axel,drift,0,0 MoveEntity r_axel,drift*1.1,0,0 PointEntity r_axel,f_axel MoveEntity r_axel,0,0,EntityDistance(r_axel,f_axel)-5 ;5 is the car length ; roll body RotateEntity body,0,0,-drift*10 ; update cam PointEntity Camera, F_Bumper PositionEntity camera,EntityX(r_axel),30,EntityZ(r_axel)-50 ; blah blah RenderWorld Text 0,0,speed Text 0,20,steer ; shite timing code t = MilliSecs()-t If t-20 < 0 Then Delay Abs(t-20) t= MilliSecs() Flip Until KeyHit(1) Function CreateWheel(Parent) Entity = CreateCylinder(12,0,Parent) RotateMesh Entity,90,90,0 ScaleMesh Entity,.5,1,1 EntityFX entity,16 EntityColor entity,50,50,50 Return Entity End Function