Status:
NOT SOLVED
How can I make an engine sound that gets louder when you speed up and clams down when your slowing down then goes to an idle when the car stops?
Is it even possible?
This is my movement code right now:
rem Set Car Max Speed
maxspeed# = 50.0
rem Main Loop
Do
SET OBJECT SPEED 1,100
rem Movement
x# = object position x(1)
z# = object position z(1)
if upkey() = 1 then accel# = 0.3
loop object 1
if downkey() = 1 then accel# = -0.5
if upkey() = 0 and downkey() = 0 then accel# = -0.1
x#=newxvalue(x#,a#,speed#) : z#=newzvalue(z#,a#,speed#)
inc speed# , accel#
if speed# > maxspeed# then speed# = maxspeed#
rem if speed# < 0.0 then speed# = 0.0
if downkey() = 0
if speed# < 0.0
speed# = 0.0
endif
endif
if downkey() = 1
if speed# < -5.0
speed# = -10.0
endif
endif
if leftkey()=1
if speed# > 0
a#=wrapvalue(a#-2.0)
endif
endif
if rightkey()=1
if speed# > 0
a#=wrapvalue(a#+2.0)
endif
endif
if leftkey()=1
if speed# = -10.0
a#=wrapvalue(a#-2.0)
endif
endif
if rightkey()=1
if speed# = -10.0
a#=wrapvalue(a#+2.0)
endif
endif
rem Setup Camera
y#=get ground height(1,x#,z#)+(object size y(1))/2
position object 1,x#,y#,z#
yrotate object 1,wrapvalue(a#+180)
rem Camera control
ca#=wrapvalue(curveangle(a#,ca#,10.0))
cx#=newxvalue(x#,ca#,-500)
cz#=newzvalue(z#,ca#,-500)
cy#=y#+200
position camera cx#,cy#,cz#
yrotate camera wrapvalue(ca#)
point camera x#,y#,z#
Sync
Loop