Thanks, I fixed it but now I have run into the ground again. When I launch the missile it works properly if I don't move, If I move (pitch up or down) the missile fires off the side and goes in the direction that you were first pointed at.
music = 1
load music "elavator.mp3",music
play music music
loop music music
set display mode 1024,768,32
`loading screen
set text font "arial" : set text size 24
set text to bold : set text transparent
rem Loading prompt
sync : center text screen width()/2,screen height()/2,"LOADING... This will take a while." : sync
`load all junk and hide mouse
startobj= 102
missilespeed=1
ship = 1
hide mouse
load object "bigship3.3ds",10
load object "missile.3ds",9
load object "redspacefighter.3ds",ship
load image "blueworld.jpg",2
load image "moon.jpg",3
load image "smoke.bmp",4
load image "missiletex.jpg",5
load image "redspacetex.jpg",6
load image "flare.jpg",7
load image "bigship3.jpg",8
`position starfighter
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
texture object ship,6
texture object 9,5
xrotate object 9,180
fix object pivot 9
texture object 10,8
position object 10, 2000,2000,2000
scale object 10 , 5000,5000,5000
rem declare all variables
speed = 0
sync on
gosub menu
main:
do
gosub player_control
gosub throttle
move object ship, speed
gosub camera_commands
gosub missile_tracker
gosub missile_launch
print missile_life
print
sync
loop
end
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#=10
height#=2
` 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
menu:
stop music 1
delete music 1
`load menu image
load image "glacticwar.jpg",1000
set text size 12
blue=RGB(0,128,255)
white=RGB(255,255,255)
selectedItem=1
do
cls
paste image 1000,0,0
`print menu items
if selectedItem=1 then ink blue,0 else ink white,0
text 300,650,"Play Game"
if selectedItem=2 then ink blue,0 else ink white,0
text 400,650,"Flight Controls"
if selectedItem=3 then ink blue,0 else ink white,0
text 580,650,"About"
if selectedItem=4 then ink blue,0 else ink white,0
text 700,650,"Exit"
`select menu items
if leftkey()=1 and hold=0 then dec selectedItem : hold=1
if rightkey()=1 and hold=0 then inc selectedItem : hold=1
if leftkey()=0 and rightkey()=0 then hold=0
if selectedItem>4 then selectedItem=1
if selectedItem<1 then selectedITem=4
`choose what to do when an item is selected
if returnkey()=1
`play game
if selectedItem=1 then goto main
`display instructions
if selectedItem=2
load image "info.jpg",1001
paste image 1001,64,32
sync : sync
`suspend()
`clear up after myself
delete image 1000
endif
`display information about the game
if selectedItem=3
`load image "media/about.bmp",1001
paste image 1001,64,32
sync : sync
`suspend()
`clear up after myself
delete image 1001
endif
`quit the game
if selectedItem=4
end
endif
endif
sync
loop
return
`positions missile
missile_tracker:
MX#=object position x (9)
MY#=object position y (9)
MZ#=object position z (9)
return
missile_launch:
`this part starts the missile, it does not move it
if spacekey() = 1 and missile_life = 0
missile_life = 1
show object 9
`! and i believe you forgot to position your bullet !
position object 9,posx#,posy#,posz#
zrotate object 9, .01
endif
if missile_life < 10000 and missile_life > 0
inc missile_life
move object 9,missilespeed
`this part stops the bullet
if missile_life > 1000
hide object 9
missile_life = 0
endif
endif
return
Thanks for the help,
Christian