Currently I'm wrapping my mind around this website:
click.
The site contains a complete Physics guide on race cars, oriented on race drivers.
I'm using it to create a realistic car demo.
This is my current progress:
sync on : sync rate 30
make matrix 1,50000,50000,50,50
make object cube 1,1
`Constants
Rear_end_ratio# = 3.07
gear_ratio# = 2.88
Wheel_dia# = 2.167
C_drag# = 0.30
front_area# = 20
p# = 0.0025
rr# = 0.696
mass# = 100
BHP = 300
diagnostics=1
create bitmap 1,1000,screen height()
do
if diagnostics=1
set cursor 0,0
print "xpos: ",xpos#
print "int(xpos): ",int(xpos#)
print "vel: ",vel#
print "T_Engine: ",T_Engine#
print "F_Wheel: ",F_Wheel#
print "F_drag: ",F_drag#
print "F_Rresist: ",F_Rresist#
print "F_net: ",F_net#
print
print "gear_ratio: ",gear_ratio#
print "gear: ",gear
print "key: ",scancode()
print
print "press enter to save graph"
endif
if spacekey()=0 then spacekey=0
if spacekey()=1 and spacekey=0 then diagnostics=1-diagnostics:spacekey=1
if returnkey()=1 and enterkey=0 then gosub savegraph : enterkey=1
if returnkey()=0 then enterkey=0
`code for the graph
set current bitmap 1
t#=t#+0.4
dot t#,screen height()-vel#/10
set current bitmap 0
`give gas
if upkey()=1 and T_Engine#<10000 then T_Engine#=T_Engine#+10
if upkey()=0 and T_Engine#>0 then T_Engine#=T_Engine#-10
`shift gears
if keystate(18)=1 and gear_change=0 and gear < 5 then gear=gear + 1 : gear_change = 1
if keystate(19)=1 and gear_change=0 and gear > -1 then gear=gear - 1 : gear_change = 1
if keystate(18)=0 and keystate(19)=0 then gear_change=0
if gear_change=1
select gear
case -1 : gear_ratio#=-3.28 : endcase
case 0 : gear_ratio#= 2.97 : endcase
case 1 : gear_ratio#= 2.07 : endcase
case 2 : gear_ratio#= 1.43 : endcase
case 3 : gear_ratio#= 1.00 : endcase
case 4 : gear_ratio#= 0.84 : endcase
case 5 : gear_ratio#= 0.56 : endcase
endselect
endif
`the formula
F_Wheel# = (T_Engine# * Rear_end_ratio# * gear_ratio#)/(Wheel_dia#/2)
F_drag# = 0.5 * C_drag# * front_area# * p# * vel#^2.
F_Rresist# = rr# * vel#
F_net# = F_Wheel# - F_drag# - F_Rresist#
acc# = F_net# / mass#
zpos_old# = zpos#
zpos# = zpos# + acc#
vel# = zpos# - zpos_old#
`placing the "car"
position object 1, xpos#, ypos#, zpos#
position camera 0,5,zpos#-10
sync
loop
savegraph:
if file exist("01.bmp") then delete file "01.bmp"
save bitmap "01.bmp",1
t=0
return
as you noticed, it's as fake as can be. That's becouse it's not complete.
- T_Engine# (engine torque) is controlled directly by the upkey
- brakes are not yet modeled
- weight distribution, supension and wheel spin are next on the list too.
I'll need a lil help on this:
first thing first: T_Engine#
the function to calculate it is not featured on the site.
I got "BHP = (T_Engine# * RPM)/ 5.252" from howstuffworks.com, that would mean "T_Engine# = (BHP * 5.252)/RPM". I fixed the rpm under the upkey, but that gives "Cannot devide by 0"
Could anyone give me a pointer as to how to calculate T_Engine#?
and what does acctually happen to the engine when you shift gears
thank you
Don't look at my sig!