Like the title says, I'm making an engine for airplane physics. It's going pretty good but.. lets just say I have some work to do.
The + and - keys on the right of the numpad control the throttle and use the arrowkeys to aim.
I have attached the airplane file and heres the source:
rem set settings
set display mode 1024,768,32
hide mouse
sync on: sync rate 60
set camera range 1,1000000000
rem make land
make matrix 1,100000,100000,200,200
rem load and scale plane
load object "H-Jet Move.3DS",1
scale object 1,200,200,200
rem set angle variable
xa#=350
rem rotate plane to face the right direction
yrotate object 1,180
do
rem angles and speed#
set cursor 10,10
print speed#
set cursor 1,1
print acceleration#
xa#=object angle x(1)
rem make it so that you turn depending on your speed and your angle while pressing up
if upkey()=1
if xa#>10
if xa#<160
xa#=wrapvalue(xa#-(speed#/25)+(xa#/640))
endif
endif
if xa#>160
xa#=wrapvalue(xa#-(speed#/50)-(xa#/3000))
endif
if xa#<10
xa#=wrapvalue(xa#-(speed#/40))
endif
endif
rem airplane automatic aimdown
if object position y(1)>10
if upkey()=0
if xa#>90
if xa#<270
xa#=xa#+.05
endif
endif
if xa#<90
if xa#>0
xa#=xa#-.05
endif
endif
if xa#<0 then xa#=360
if xa#<=360
if xa#>270
xa#=xa#-.05
endif
endif
endif
endif
rem make it so that you turn depending on your speed and your angle while pressing down
if downkey()=1
if xa#>10
if xa#<160
xa#=wrapvalue(xa#+(speed#/30)-(xa#/640))
endif
endif
if xa#>160
xa#=wrapvalue(xa#+(speed#/30)+(xa#/3000))
endif
if xa#<=10
xa#=wrapvalue(xa#+(speed#/40))
endif
endif
if keystate(78)=1
if acceleration#<10
acceleration#=acceleration#+.005
endif
endif
if keystate(74)=1
if acceleration#>0
acceleration#=acceleration#-.005
endif
endif
rem set speed max and min to accleeration
if speed#<acceleration#
speed#=speed#+.003
endif
if speed#>acceleration#
speed#=speed#-.003
endif
rem control movement
if rightkey()=1
ya#=ya#+.1
yrotate object 1,ya#-180
endif
if keystate(51)=1
za#=za#+.5
zrotate object 1,za#
endif
if keystate(51)=0
za#=za#-.02
zrotate object 1,za#
endif
if keystate(52)=1
za#=za#-.5
zrotate object 1,za#
endif
if keystate(52)=0
za#=za#+.02
zrotate object 1,za#
endif
if leftkey()=1
if za#<16
za#=za#+.5
zrotate object 1,za#
endif
ya#=ya#-.1
yrotate object 1,ya#-180
endif
if leftkey()=0
if rightkey()=0
if za#>0
za#=za#-.02
zrotate object 1,za#
endif
endif
endif
y#=object position y(1)
rem freefall
if y#>1
if speed#<1
y#=y#-2
xa#=xa#+.1
ya#=ya#+.5
position object 1,object position x(1),y#,object position z(1)
endif
endif
rotate limb 1,5,0,10,0
rem move airplane
move object 1,speed#-speed#-speed#
xrotate object 1,xa#
zrotate object 1,za#
yrotate object 1,ya#-180
rem set camera to follow plane
set camera to follow object position x(1),object position y(1),object position z(1),0,30,15,5,1
rem syncronization
sync
loop
Oh, and here's the airplane image:
[/href]
Visit my Airplane Engine thread in the WIP board.