Here, thanks to Jess Ticular and Shawn of 3D Starwraith for their invaluable help I thought I would share this so anyone stuck dong a flight/space sim could now have a very professional player fighter /space plane, You have Joystick Hat controls (Thank you Shaun) and 1st/3rd Person camera controls (Thank you Jess) As people have helped me I think I should give back and help someone else, also has afterburner's in the code. Add your own weapons, autopilot, countermeasures and flight model
rem DARK BASIC EXAMPLE PROGRAM 18
rem ==========================================
rem This program shows free flight movement with H.O.T.A.S sticks
rem ------------------------------------------
rem updated by Vampyre(Ian George)
autocam off
hide mouse
sync on
rem Make wire sky sphere
make object sphere 1,5000
set object 1,0,0,0
rem Make flying object
make object box 2,150,5,20
make mesh from object 2,2
delete object 2
make object box 2,25,15,100
add limb 2,1,2
position object 2,0,0,500
rem Make drone to mark a back position
make object sphere 3,10
rem Set camera range
set camera range 1,10000
rem Set text font
set text font "Arial"
ink rgb(255,255,0),0
set text size 30
rem Main loop
do
rem User prompt
center text 320,0,"FREE FLIGHT ORIENTATION"
center text 320,25,"If you Have any USB H.O.T.A.S System ,"
center text 320,50,"Use the Joystick to Pitch Up and Down"
center text 320,70,"Use Your H.O.T.A.S. Rudders to Roll"
center text 320,90,"Use Your Joystick Throttle to Move"
center text 320,120,"Use SPACE to Reset"
rem Control free flight object
if joystick up() then pitch object up 2,5
if joystick down() then pitch object down 2,5
if joystick twist z()=1000 then turn object left 2,5
if joystick twist z()=-1000 then turn object right 2,5
if joystick right()=1 then roll object left 2,5
if joystick left()=1 then roll object right 2,5
if joystick slider a()=0 then move camera 20 : move object 2,40
if joystick fire x(4)=1 then move camera 20 : move object 2,100
if joystick z=1000 then move camera 20 : move object ,100
if spacekey()=1 then rotate object 2,0,0,0
rem HAT control
jhat=joystick hat angle(0)
text 320,140,"HAT signal: "+str$(jhat)
rem **** use these lines below if you want the view to be immediate
rem **** and rem out the other lines that aren't needed
rem **** integrity checks for code alterations are included
rem turnview=0
rem if jhat=27000 or jhat=31500 then turnview=-90
rem if jhat=9000 or jhat=4500 then turnview=90
rem if jhat=18000 or jhat=13500 or jhat=22500 then turnview=180
rem horizontal view position
if turnview>0 and turnview<180 then turnview=turnview-2:if turnview<0 then turnview=0
if turnview>179 then turnview=turnview+2:if turnview>359 then turnview=0
if jhat=27000 or jhat=31500 or jhat=22500 then turnview=wrapvalue(turnview-4):if turnview>180 and turnview<220 then turnview=220
if jhat=9000 or jhat=4500 or jhat=13500 then turnview=wrapvalue(turnview+4):if turnview<180 and turnview>140 then turnview=140
rem vertical view position
if pitchview>0 and pitchview<180 then pitchview=pitchview-2:if pitchview<0 then pitchview=0
if pitchview>179 then pitchview=pitchview+2:if pitchview>359 then pitchview=0
if jhat=18000 or jhat=13500 or jhat=22500 then pitchview=wrapvalue(pitchview-4):if pitchview>180 and pitchview<280 then pitchview=280
if jhat=0 or jhat=4500 or jhat=31500 then pitchview=wrapvalue(pitchview+4):if pitchview<180 and pitchview>80 then pitchview=80
If InKey$() = "1" And cammode = 0 Then cammode = 1 : `Set the camera mode to third person
If InKey$() = "2" And cammode = 1 Then cammode = 0 : `Set the camera mode to first person
If cammode = 0
rem Place camera and set orientation to object
position camera object position x(2),object position y(2),object position z(2)
set camera to object orientation 2
EndIf
If cammode = 1
rem Place camera and set orientation to object
position camera object position x(3),object position y(3),object position z(3)
set camera to object orientation 2
EndIf
rem Get back position of object for camera
pitch object down 2,11
move object 2,-150
position object 3,object position x(2),object position y(2),object position z(2)
move object 2,150
pitch object up 2,11
hide object 3
rem now set turnview as needed for HAT control
turn camera right turnview
pitch camera up pitchview
rem Update screen
sync
rem and reset the camera view back to normal to center everything
turn camera left turnview
loop
Here is the code with the pedals controlling left and right
rem DARK BASIC EXAMPLE PROGRAM 18
rem ==========================================
rem This program shows free flight movement with H.O.T.A.S sticks
rem ------------------------------------------
rem updated by Vampyre(Ian George)
autocam off
hide mouse
sync on
rem Make wire sky sphere
make object sphere 1,5000
set object 1,0,0,0
rem Make flying object
make object box 2,150,5,20
make mesh from object 2,2
delete object 2
make object box 2,25,15,100
add limb 2,1,2
position object 2,0,0,500
rem Make drone to mark a back position
make object sphere 3,10
rem Set camera range
set camera range 1,10000
rem Set text font
set text font "Arial"
ink rgb(255,255,0),0
set text size 30
rem Main loop
do
rem User prompt
center text 320,0,"FREE FLIGHT ORIENTATION"
center text 320,25,"If you Have any USB H.O.T.A.S System ,"
center text 320,50,"Use the Joystick to Pitch Up and Down"
center text 320,70,"Use Your H.O.T.A.S. Rudders to Roll"
center text 320,90,"Use Your Joystick Throttle to Move"
center text 320,120,"Use SPACE to Reset"
rem Control free flight object
if joystick up() then pitch object up 2,5
if joystick down() then pitch object down 2,5
if joystick right()=1 then turn object left 2,5
if joystick left()=1 then turn object right 2,5
if joystick twist z()=1000 then roll object left 2,5
if joystick twist z()=-1000 then roll object right 2,5
if joystick slider a()=0 then move camera 20 : move object 2,40
if scancode()=15 then move camera 20 : move object 2,100
if joystick fire x(4)=1 then move camera 20 : move object 2,100
if spacekey()=1 then rotate object 2,0,0,0
rem HAT control
jhat=joystick hat angle(0)
text 320,140,"HAT signal: "+str$(jhat)
rem **** use these lines below if you want the view to be immediate
rem **** and rem out the other lines that aren't needed
rem **** integrity checks for code alterations are included
rem turnview=0
rem if jhat=27000 or jhat=31500 then turnview=-90
rem if jhat=9000 or jhat=4500 then turnview=90
rem if jhat=18000 or jhat=13500 or jhat=22500 then turnview=180
rem horizontal view position
if turnview>0 and turnview<180 then turnview=turnview-2:if turnview<0 then turnview=0
if turnview>179 then turnview=turnview+2:if turnview>359 then turnview=0
if jhat=27000 or jhat=31500 or jhat=22500 then turnview=wrapvalue(turnview-4):if turnview>180 and turnview<220 then turnview=220
if jhat=9000 or jhat=4500 or jhat=13500 then turnview=wrapvalue(turnview+4):if turnview<180 and turnview>140 then turnview=140
rem vertical view position
if pitchview>0 and pitchview<180 then pitchview=pitchview-2:if pitchview<0 then pitchview=0
if pitchview>179 then pitchview=pitchview+2:if pitchview>359 then pitchview=0
if jhat=18000 or jhat=13500 or jhat=22500 then pitchview=wrapvalue(pitchview-4):if pitchview>180 and pitchview<280 then pitchview=280
if jhat=0 or jhat=4500 or jhat=31500 then pitchview=wrapvalue(pitchview+4):if pitchview<180 and pitchview>80 then pitchview=80
If InKey$() = "1" And cammode = 0 Then cammode = 1 : `Set the camera mode to third person
If InKey$() = "2" And cammode = 1 Then cammode = 0 : `Set the camera mode to first person
If cammode = 0
rem Place camera and set orientation to object
position camera object position x(2),object position y(2),object position z(2)
set camera to object orientation 2
EndIf
If cammode = 1
rem Place camera and set orientation to object
position camera object position x(3),object position y(3),object position z(3)
set camera to object orientation 2
EndIf
rem Get back position of object for camera
pitch object down 2,11
move object 2,-150
position object 3,object position x(2),object position y(2),object position z(2)
move object 2,150
pitch object up 2,11
hide object 3
rem now set turnview as needed for HAT control
turn camera right turnview
pitch camera up pitchview
rem Update screen
sync
rem and reset the camera view back to normal to center everything
turn camera left turnview
loop
And here is a version using the keyboard as a throttle
rem DARK BASIC EXAMPLE PROGRAM 18
rem ==========================================
rem This program shows free flight movement with H.O.T.A.S sticks
rem ------------------------------------------
rem updated by Vampyre(Ian George)
autocam off
hide mouse
sync on
rem Make wire sky sphere
make object sphere 1,10000
set object 1,0,0,0
rem Make flying object
make object box 2,150,5,20
make mesh from object 2,2
delete object 2
make object box 2,25,15,100
add limb 2,1,2
position object 2,0,0,500
rem Make drone to mark a back position
make object sphere 3,10
rem Set camera range
set camera range 1,10000
rem Set text font
set text font "Arial"
ink rgb(255,255,0),0
set text size 30
rem Main loop
do
rem User prompt
center text 320,0,"FREE FLIGHT ORIENTATION"
center text 320,25,"If you have a joystick with hat and keyboard,"
center text 320,50,"Use the Joystick to Pitch Up and Down and turn left & right"
center text 320,70,"Use the left and right cursur keys to Roll"
center text 320,90,"Use the Up cursur key to Move"
center text 320,120,"Use SPACE to Reset"
rem Control free flight object
if joystick up()=1 then pitch object up 2,5
if joystick down()=1 then pitch object down 2,5
if joystick left()=1 then turn object left 2,5
if joystick right()=1 then turn object right 2,5
if leftkey()=1 then roll object left 2,5
if rightkey()=1 then roll object right 2,5
if upkey()=1 then move camera 20 : move object 2,20
if joystick fire x(3)=1 then move camera 20 : move object 2,100
if scancode()=15 then move camera 20 : move object 2,100
if spacekey()=1 then rotate object 2,0,0,0
rem HAT control
jhat=joystick hat angle(0)
text 320,160,"HAT signal: "+str$(jhat)
rem **** use these lines below if you want the view to be immediate
rem **** and rem out the other lines that aren't needed
rem **** integrity checks for code alterations are included
rem turnview=0
rem if jhat=27000 or jhat=31500 then turnview=-90
rem if jhat=9000 or jhat=4500 then turnview=90
rem if jhat=18000 or jhat=13500 or jhat=22500 then turnview=180
rem horizontal view position
if turnview>0 and turnview<180 then turnview=turnview-2:if turnview<0 then turnview=0
if turnview>179 then turnview=turnview+2:if turnview>359 then turnview=0
if jhat=27000 or jhat=31500 or jhat=22500 then turnview=wrapvalue(turnview-4):if turnview>180 and turnview<220 then turnview=220
if jhat=9000 or jhat=4500 or jhat=13500 then turnview=wrapvalue(turnview+4):if turnview<180 and turnview>140 then turnview=140
rem vertical view position
if pitchview>0 and pitchview<180 then pitchview=pitchview-2:if pitchview<0 then pitchview=0
if pitchview>179 then pitchview=pitchview+2:if pitchview>359 then pitchview=0
if jhat=18000 or jhat=13500 or jhat=22500 then pitchview=wrapvalue(pitchview-4):if pitchview>180 and pitchview<280 then pitchview=280
if jhat=0 or jhat=4500 or jhat=31500 then pitchview=wrapvalue(pitchview+4):if pitchview<180 and pitchview>80 then pitchview=80
If InKey$() = "1" And cammode = 0 Then cammode = 1 : `Set the camera mode to third person
If InKey$() = "2" And cammode = 1 Then cammode = 0 : `Set the camera mode to first person
If cammode = 0
rem Place camera and set orientation to object
position camera object position x(2),object position y(2),object position z(2)
set camera to object orientation 2
EndIf
If cammode = 1
rem Place camera and set orientation to object
position camera object position x(3),object position y(3),object position z(3)
set camera to object orientation 2
EndIf
rem Get back position of object for camera
pitch object down 2,11
move object 2,-150
position object 3,object position x(2),object position y(2),object position z(2)
move object 2,150
pitch object up 2,11
hide object 3
rem now set turnview as needed for HAT control
turn camera right turnview
pitch camera up pitchview
rem Update screen
sync
rem and reset the camera view back to normal to center everything
turn camera left turnview
loop
I also have one for the Thrustmaster Attack Throttle I will put it up in due course.