Here's a little helicopter sim that I made.
I don't know if it will work in DBP as well.
download the media.zip file and extract it to the same folder that the code is in.
5 line version:
sync on : sync rate 100 : start# = timer() : autocam off : make object plain 1,1,500 : make object plain 2,1,500 : make object plain 3,10000,10000 : make object sphere 5,2000 : make object plain 6,10,2000 : make mesh from object 1,6 : add limb 6,1,1 : rotate limb 6,1,0,0,30 : add limb 6,2,1 : rotate limb 6,2,0,0,60 : add limb 6,3,1 : rotate limb 6,3,0,0,90 : ghost object on 5 : ghost object on 6 : load sound "heli.wav",1 : load sound "explode.wav",2 : load image "Grass15.bmp",1 : texture object 3,1 : Zrotate object 1,10 : Zrotate object 2,350 : Xrotate object 3,90
Xrotate object 6,90 : scale object 5,100,0.001,100 : lock object on 1 : lock object on 2 : lock object on 5 : lock object on 6 : position object 1,-25,0,50 : position object 2,25,0,50 : position object 5,0,200,60 : position object 6,0,200,60 : position camera 0,100,0 : make object box 4,1,1,1 : hide object 4 : thrust# = 0.005 : xpos# = camera position x() : ypos# = camera position y() : zpos# = camera position z() : set camera range 1,10000 : rotspeed# = 1 : ymo = -0.1 : grav = 399-(0.01*3880) : loop sound 1 : do : set sound volume 1,(thrust#+0.1)*500 : inc rotspeed#,mousemovex()
pitch# = mousemovey() : pitch camera down pitch#/2 : turn camera right rotspeed#/20 : if upkey() = 1 : inc thrust#,0.0001 : endif : if downkey() = 1 : dec thrust#,0.0001 : endif : if rightkey() = 1 : roll camera right 0.1 : endif : if leftkey() = 1 : roll camera left 0.1 : endif : if thrust#<0 : thrust# = 0 : endif : if thrust#>0.1 : thrust# = 0.1 : endif : position object 4,0,0,0 : set object to camera orientation 4 : pitch object up 4,90 : move object 4,thrust#
pitch object down 4,90 : inc xmo#,object position x(4) : ymo# = curvevalue((object position y(4)*10),ymo#,10) : inc zmo#,object position z(4) : inc fallspd#,(0.01-thrust#) : if fallspd#<0 : fallspd#=0 : endif : dec ymo#,fallspd#/10 : inc xpos#,xmo# : inc ypos#,ymo# : inc zpos#,zmo# : position camera xpos#,ypos#,zpos# : if ypos# < 1 : set camera view 0,0,1,1 : stop sound 1 : play sound 2 : cls rgb(255,128,0) : sync : wait 100 : cls 0 : ink rgb(255,255,255),0 : print "You lasted: "; : print ((timer()-start#)/1000); : print " seconds!"
sync : suspend for key : end : endif : if count=5 : count=0 : inc rot#,(250*thrust#)+259 : rot# = wrapvalue(rot#) : Zrotate object 6,rot# : endif : inc count : ink 0,0 : line 10,10,30,10 : line 30,10,30,400 : line 30,400,10,400 : line 10,400,10,10 : ink rgb(255,0,0),0 : box 11,399-(thrust#*3880),29,399 : ink rgb(255,255,0),0 : line 11,grav,29,grav : sync : loop
longer version - sorry, I always forget to comment.
sync on : sync rate 100
start# = timer()
autocam off
make object plain 1,1,500
make object plain 2,1,500
make object plain 3,10000,10000
make object sphere 5,2000
make object plain 6,10,2000
make mesh from object 1,6
add limb 6,1,1 : rotate limb 6,1,0,0,30
add limb 6,2,1 : rotate limb 6,2,0,0,60
add limb 6,3,1 : rotate limb 6,3,0,0,90
ghost object on 5
ghost object on 6
load sound "heli.wav",1
load sound "explode.wav",2
load image "Grass15.bmp",1
texture object 3,1
Zrotate object 1,10
Zrotate object 2,350
Xrotate object 3,90
Xrotate object 6,90
scale object 5,100,0.001,100
lock object on 1
lock object on 2
lock object on 5
lock object on 6
position object 1,-25,0,50
position object 2,25,0,50
position object 5,0,200,60
position object 6,0,200,60
position camera 0,100,0
make object box 4,1,1,1
hide object 4
thrust# = 0.005
xpos# = camera position x()
ypos# = camera position y()
zpos# = camera position z()
set camera range 1,10000
rotspeed# = 1 : ymo = -0.1
grav = 399-(0.01*3880)
loop sound 1
do
set sound volume 1,(thrust#+0.1)*500
inc rotspeed#,mousemovex()
pitch# = mousemovey()
pitch camera down pitch#/2
turn camera right rotspeed#/20
if upkey() = 1 then inc thrust#,0.0001
if downkey() = 1 then dec thrust#,0.0001
if rightkey() = 1 then roll camera right 0.1
if leftkey() = 1 then roll camera left 0.1
if thrust#<0 then thrust# = 0
if thrust#>0.1 then thrust# = 0.1
position object 4,0,0,0
set object to camera orientation 4
pitch object up 4,90 : move object 4,thrust# : pitch object down 4,90
inc xmo#,object position x(4)
ymo# = curvevalue((object position y(4)*10),ymo#,10)
inc zmo#,object position z(4)
inc fallspd#,(0.01-thrust#)
if fallspd#<0 then fallspd#=0
dec ymo#,fallspd#/10
inc xpos#,xmo#
inc ypos#,ymo#
inc zpos#,zmo#
position camera xpos#,ypos#,zpos#
if ypos# < 1
set camera view 0,0,1,1
stop sound 1
play sound 2
cls rgb(255,128,0)
sync : wait 100
cls 0
ink rgb(255,255,255),0
print "You lasted: ";
print ((timer()-start#)/1000);
print " seconds!"
sync
suspend for key
end
endif
if count=5
count=0
inc rot#,(250*thrust#)+259
rot# = wrapvalue(rot#)
Zrotate object 6,rot#
endif
inc count
ink 0,0
line 10,10,30,10
line 30,10,30,400
line 30,400,10,400
line 10,400,10,10
ink rgb(255,0,0),0
box 11,399-(thrust#*3880),29,399
ink rgb(255,255,0),0
line 11,grav,29,grav
sync
loop
I've still got 15 lines to improve it on, so if you have any suggestions?
There are three types of people, those that can count and those that can't.