This is very very rough, but it might give you a starting point. It's the result of trying to build my own vehicle system, forgot I even had it until I saw this thread.
`Initiate physics engine
phy start
phy update 0
`Load game media
`make materials for car
phy make material 1,"car"
phy set material dynamic friction 1,16
phy set material restitution 1,0.1
phy set material static friction 1,3
phy build material 1
`make material for tires
phy make material 2,"tire"
phy set material dynamic friction 2,0.5
phy set material restitution 2,1
phy build material 2
`make material for ground
phy make material 3,"ground"
phy set material dynamic friction 3,1
phy set material restitution 3,0.3
phy build material 3
`Load player car objects
make object cube 1,2
scale object 1,100,100,200
position object 1,0,3,0
color object 1,rgb(0,0,255)
`Make player car objects rigid bodies and assign materials
phy make rigid body dynamic box 1,1
phy set rigid body mass 1,100
`Load wheels
for w = 10 to 13
make object sphere w,0.2,10,10
color object w,rgb(10,10,10)
scale object w,500,100,500
rotate object w,0,0,90
next w
position object 10,-1.2,2,-2
position object 11,1.2,2,-2
position object 12,-1.2,2,2
position object 13,1.2,2,2
for c = 10 to 13
phy make rigid body dynamic sphere c,2
phy set rigid body mass c,20
phy make 6dof joint c,1,c
phy set 6dof joint global axis c,1,1,0,0
phy set 6dof joint global axis c,0,1,0,0
select c
case 10
phy set 6dof joint global anchor c,1,-1.2,2,-2
phy set 6dof joint swing2 motion c,0
endcase
case 11
phy set 6dof joint global anchor c,1,1.2,2,-2
phy set 6dof joint swing2 motion c,0
endcase
case 12
phy set 6dof joint global anchor c,1,-1.2,2,2
phy set 6dof joint swing2 motion c,1
phy set 6dof joint swing2 limit c,0,0,20,0
`phy set rigid body angular damping c,2
endcase
case 13
phy set 6dof joint global anchor c,1,1.2,2,2
phy set 6dof joint swing2 motion c,1
phy set 6dof joint swing2 limit c,0,0,20,0
`phy set rigid body angular damping c,2
endcase
endselect
phy set 6dof joint motion y c,0
phy set 6dof joint motion z c,0
phy set 6dof joint motion x c,0
phy set 6dof joint swing1 motion c,0
phy build 6dof joint c
next c
`Load area terrain
make object cube 2,1
scale object 2,10000,1,10000
position object 2,0,0,0
`Make matrial for terrain
`Make terrain static rigid body
phy make rigid body static box 2,3
`Turn gravity on
phy set gravity 0,-9.8,0
`Temp position for camera
position camera 50,10,-50
rotate camera 30,-45,0
`Gameplay loop
do
`Start physics update
phy update 1
`Make camera follow player vehicle
`Get player car position
px# = object position x(1)
py# = object position y(1)
pz# = object position z(1)
`Position camera
set camera to follow px#,py#,pz#,0,6,1.5,2,0
`Simple control system
if upkey() = 1
phy add rigid body local torque 10,0,-60,0,4
phy add rigid body local torque 11,0,-60,0,4
endif
if downkey() = 1
phy add rigid body local torque 10,0,30,0,4
phy add rigid body local torque 11,0,30,0,4
endif
if leftkey() = 1
phy add rigid body torque 12,0,-0.1,0,1
phy add rigid body torque 13,0,-0.1,0,1
endif
if rightkey() = 1
phy add rigid body torque 12,0,0.1,0,1
phy add rigid body torque 13,0,0.1,0,1
endif
`Get collision data
while phy get collision data() = 1
a = phy get collision object a()
b = phy get collision object b()
endwhile
`Commands
`Refresh physics and screen
phy update 0
sync
`End of loop
loop