Free Flight Mod for H.O.T.A.S USB Joysticks by vampyre26th Aug 2004 1:44
|
---|
Summary Very modified flight control for H.O.T.A.S joysticks includes hat view control so you can look around while flying, very useful for space/flight player planes Description Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com 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)special thanks to Shauno of Starwraith 3D and Jess rem Ticular 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 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,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 |