WAHAY - FINALLY GOT IT SUSSED AND HAVE PROVED ONCE AND FOR ALL THAT FREE-FLIGHT COMMANDS ARE FIXED!!!!!!!!!!!!!!!
This demo will allow you to fly a spaceship using all the free-flight commands and also demonstrates how to use different camera angles properly.
Enjoy....
sync on : sync rate 0 : autocam off : randomize timer()
` create stars image
for f=1 to 50 : e=rnd(255) : dot rnd(255),rnd(255),rgb(e,e,e) : next f : get image 1,0,0,256,256
` create spaceship images
cls rgb(192,192,192) : ink rgb(0,0,0),0
for f=1 to 100 : line rnd(255),rnd(255),rnd(256),rnd(256) : next f
get image 2,64,64,128,128
cls rgb(255,0,0) : get image 3,0,0,2,2
` create star sphere
make object sphere 9,20000,20,20 : texture object 9,1
scale object texture 9,8,8 : set object 9,1,0,0,0,0,0,0
` dodgy looking spaceship
make object box 1,20,6,50 : texture object 1,2
make object cube 2,2 : glue object to limb 2,1,0 : position object 2,-5,0,-25 : texture object 2,3
make object cube 3,2 : glue object to limb 3,1,0 : position object 3,5,0,-25 : texture object 3,3
make object box 4,10,7,10 : turn object left 4,45 : glue object to limb 4,1,0 : position object 4,0,0,25 : texture object 4,2
` framework
o=99 : s=3000 : c=5
for f=0 to c-1
for g=0 to c-1
inc o : make object box o,s,2,2 : position object o,s/2,g*s/(c-1),f*s/(c-1) : color object o,rgb(255,0,0)
inc o : make object box o,2,s,2 : position object o,f*s/(c-1),s/2,g*s/(c-1) : color object o,rgb(0,255,0)
inc o : make object box o,2,2,s : position object o,f*s/(c-1),g*s/(c-1),s/2 : color object o,rgb(0,0,255)
next g
next f
set camera range 1,20000 : cam=1 : s#=0 : ink rgb(255,255,255),0
do
position camera object position x(1),object position y(1),object position z(1)
if keystate(203)=1 then roll camera left 1 : roll object left 1,1
if keystate(205)=1 then roll camera right 1 : roll object right 1,1
if keystate(200)=1 then pitch camera down 1 : pitch object down 1,1
if keystate(208)=1 then pitch camera up 1 : pitch object up 1,1
if keystate(12)=1 then s#=s#-0.1 : if s# < 0 then s#=0
if keystate(13)=1 then s#=s#+0.1
if keystate(23)=1 then turn camera left 1 : turn object left 1,1
if keystate(25)=1 then turn camera right 1 : turn object right 1,1
if keystate(2)=1 and cam <> 1 then cam=1
if keystate(3)=1 and cam <> 2 then cam=2
if keystate(4)=1 and cam <> 3 then cam=3
if keystate(5)=1 and cam <> 4 then cam=4
move camera s# : move object 1,s#
select cam
case 1 : pitch camera down 10 : move camera -100 : pitch camera up 10 : endcase
case 2 : pitch camera down 10 : turn camera right 20 : move camera -70 : turn camera left 20 : pitch camera up 10 : endcase
case 3 : pitch camera down 10 : turn camera left 20 : move camera -70 : turn camera right 20 : pitch camera up 10 : endcase
case 4 : pitch camera down 90 : move camera -200 : endcase
endselect
set cursor 0,0
print "FREE FLIGHT DEMO - By Spooky" : print
print "Up Arrow = Pitch Down"
print "Down Arrow = Pitch Up"
print
print "Left Arrow = Roll Left"
print "Right Arrow = Roll Right"
print
print "I = Turn Left"
print "P = Turn Right"
print
print "+ = Accelerate"
print "- = Decelerate"
print
print "1 2 3 4 = Select Camera"
print
print "Cur. Camera = ";cam
print
print "Cur. Key = ";scancode()
position object 9,object position x(1),object position y(1),object position z(1)
sync
` reset any cameras NOT pointing forward
if cam=4 then pitch camera up 90
loop
The programmer formerly known as sonic