Here is my problem I am creating a 3D space shooter... When I turn my throttle up to max power and my speed increases the ship bounces all about. I know what is wrong... the values are so large that the computer is rounding them and making it jump. What would be the best way to limit the speed while still making it look like your moving very fast? I tried FOV but found that it makes my planets look oddly shaped...
here is my code:
`load all junk and hide mouse
ship = 1
hide mouse
load object "starfighter.3ds",ship
load image "blueworld.jpg",2
load image "moon.jpg",3
`position starfighter and scale down
position object ship, 20,20,20
rotate object ship, 0,90,0
fix object pivot ship
rem stars
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
rem star sphere
make object sphere 99,30000000000000,20,20 : texture object 99,1
scale object texture 99,8,8 : set object 99,1,0,0,0,0,0,0
rem set camera to see stars
set camera range 1,30000000000000
rem create planet
make object sphere 100,2300000,20,20 : texture object 100,2
position object 100, 2300000,2300000,23000
`create a moon for our planet
make object sphere 101,400000,20,20 :texture object 101,3
position object 101,2300000+43000,230000+ 33000,4000
rem declare all variables
speed = 0
sync on
do
gosub player_control
gosub throttle
move object ship, speed
gosub camera_commands
sync
loop
rem takes care of all speed issues
throttle:
if upkey() = 1 then speed = speed + 1
if downkey() = 1 then speed = speed - 1
if speed < 1 then speed = 1
if speed > 200 then speed = 200
return
` tracks ship
camera_commands:
posx#=object position x (ship)
posy#=object position y (ship)
posz#=object position z (ship)
posay#=object angle y (ship)
posax#=object angle x (ship)
posaz#=object angle z (ship)
distance#=25
height#= 3
` set camera to follow posx#,posy#,posz#,80,distance#,hight#,0,0
set camera to object orientation ship
position camera posx#,posy#,posz#
move camera -distance#
pitch camera up 90
move camera height#
pitch camera down 90
return
`all of the free flight controls
player_control:
if keystate(17) = 1 then pitch object down ship,.5
if keystate(31) = 1 then pitch object up ship,.5
if keystate(30) = 1 and st = 0 then roll object left ship,.5 else if keystate(30) = 1 and st = 1 then tr = tr - 1
if keystate(32) = 1 and st = 0 then roll object right ship,.5 else if keystate(32) = 1 and st = 1 then tr = tr + 1
if tr < -15 then tr = -15
if tr > 15 then tr = 15
if tr < 0 then tr = tr + 0.1
if tr > 0 then tr = tr - 0.1
roll object right ship,tr
return
I also included the ship in the download button