TGC Codebase Backup



Joystick Flight Sim by guru of boredom

27th Oct 2003 21:25
Summary

A basic joystick flight sim with an engine stall effect



Description

Use joystick up/down to move up and down
left/right to roll left and right
hat left/right to turn left and right
Fire button C and D to speed up or slow down
if your speed is below 7 you stall!



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    set display mode 640, 480, 32
hide mouse
disable escapekey

speed#=12
thrust#=12
autocam off

`matrix
make matrix 1,10000,10000,50,50
randomize matrix 1, 50

` plane
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,5000,500,5000

` drone for camera
make object sphere 3,10

` camera range
set camera range 1,10000


sync on



do
sync

if joystick left()=1 then roll object left 2, 2
if joystick right()=1 then roll object right 2, 2
if joystick down()=1 then pitch object up 2, 2
if joystick up()=1 then pitch object down 2, 2
` hat switch commands
if joystick hat angle(0)=9000 then turn object right 2, 2
if joystick hat angle(0)=27000 then turn object left 2, 2


if joystick fire c()=1 then thrust#=thrust#+.25
if thrust#>50 then thrust#=50
if joystick fire d()=1 then thrust#=thrust#-.5
if thrust#<0 then thrust#=0

speed#=curvevalue(thrust#,speed#,25)

move object 2, speed#
`stall
if speed#<12 then position object 2, object position x(2), object position y(2)-(15-speed#), object position z(2)
if speed#<7 then position object 2, object position x(2), object position y(2)-(9-speed#),object position z(2):set cursor 1,1:print "STALL!"
set cursor 50,1

print speed#
set cursor 120,1
altitude#=object position y(2)
print altitude#

` camera controls
` get drone pos.
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
` move camera
position camera object position x(3),object position y(3), object position z(3)
set camera to object orientation 2



loop