TGC Codebase Backup



Combination Control Thrusmaster Attack Throttle by vampyre

1st Jul 2007 11:27
Summary

Same as the Combination control aircraft except it is fo the Attack Throttle



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    REM ***************************************************************
REM ***************************************************************
REM ***************************************************************
REM ***************************************************************
REM  Flight VTOL Thustmaster Attack Throttle & Z Axis throttle 
REM  control 2
REM  Author :Ian George aka  Vampyre
REM ****************************************************************
REM ****************************************************************
REM ****************************************************************
REM ****************************************************************

autocam off
hide mouse
sync rate 60
sync on

Make matrix 1,10000,10000,20,20

Rem texture matrix
Load image "grass09.bmp",1
Prepare matrix texture 1,1,1,1
Fill matrix 1,0,1

rem Randomize the matrix
randomize matrix 1,125
update matrix 1
X#=5000
Z#=5000


rem Make drone to mark a back position
make object sphere 3,10
hide object 3

rem Aircraft Object
load object "TESTBOX.X", 2

rem Rotate and fix data so character faces right way
xrotate object 2,0
yrotate object 2,180
zrotate object 2,0
fix object pivot 2
position object 2,x,150,z


rem scaling 
scale object 2,1000,1000,1000
cammode = 0


rem Set text font
set text font "Westminister"
ink rgb(200,255,0),0
set text size 15

do

  rem movement
   mmy=mousemovey()
   mmx=mousemovex()
   if mmy>0 then pitch object up 2,5
   if mmy<0 then pitch object down 2,5
   if mmx<0 then turn object left 2,5
   if mmx>0 then turn object right 2,5
   if upkey()=1 then move object 2,40
   if downkey()=1 then move object 2,-40
   if scancode()=17 then move object 2,40
   if scancode()=32 then move object 2,-40
   if inkey$() = "q" then roll object left 2,5
   if inkey$() = "e" then roll object right 2,5
   if scancode()=211 then roll object left 2,5
   if scancode()=209 then roll object right 2,5
   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 joystick twist z()=1000 then roll object left 2,5
   if joystick twist z()=-1000 then roll object right 2,5
   if joystick z()=-1000 then move object 2,40
   if joystick z()=1000 then move object 2,-40

 REM Straffe Left
  if joystick fire x(8)=1
  turn object left 2,90 : move object 2,20 : turn object right 2,90
  endif

  REM Straffe Right
  if joystick  fire x(9)=1
  turn object right 2,90 : move object 2,20 : turn object left 2,90
  endif
REM Straffe Left
  if scancode()=30
  turn object left 2,90 : move object 2,20 : turn object right 2,90
  endif
  
  REM Straffe Right
  if scancode()=32
  turn object right 2,90 : move object 2,20 : turn object left 2,90
  endif
  
  REM Straffe Left
  if leftkey()=1
  turn object left 2,90 : move object 2,20 : turn object right 2,90
  endif
  
  REM Straffe Right
  if rightkey()=1
  turn object right 2,90 : move object 2,20 : turn object left 2,90
  endif

rem VTOL take off and landing
if controlkey()=1 or joystick fire x(6)
   position object 2,object position x(2),object position y(2)+height,object position z(2)
  height=10
endif
if spacekey()=1 or joystick fire x(7)
   position object 2,object position x(2),object position y(2)-10,object position z(2)
  height=height-1
endif


  rem HAT control
  jhat=joystick hat angle(0)

  print westminster
  text 10,10,"HAT signal: "+str$(jhat)
  text 10,20,"Joystick:   "+str$(jx)+"/"+str$(jy)
  text 10,30,"Slider:     "+str$(joystick slider a())
  text 10,40,"FPS:        "+str$(screen fps())



  intspeed=int(speed#*150)
  intspeed=int(speed#-150)

  if timer()>t
  rem then we add another half second to t
  t=timer()+500
  rem so the IF part of this bit will only be true when timer() is equal to t
  endif





  rem Set the hat look flags to nothing
  lookUp = 0: lookLeft = 0: lookRight = 0: lookBack = 0
  if jhat = 0 then lookUp = 1
  if jhat=9000 or jhat=4500 or jhat=13500 then lookRight = 1
  if jhat=31500 or jhat=27000 or jhat=22500 then lookLeft = 1
  if jhat = 18000 then lookBack = 1

  If InKey$() = "1" Then cammode = 1 : ` third person
  If InKey$() = "2" Then cammode = 0 : ` first person

   If cammode = 0
     rem Place camera and set orientation to object for FPS
     position camera object position x(2),object position y(2),object position z(2)
     set camera to object orientation 2

     if lookRight = 1 then turn camera right 90.0
     if lookLeft = 1  then turn camera left 90.0
     if lookUp = 1    then pitch camera up 45.0
     if lookBack = 1  then turn camera right 180.0
   else


    rem Place as over head for 3rd person

    move object 2,-150
    position object 3,object position x(2),object position y(2),object position z(2)
    move object 2,150



   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
 sync
loop