I didn't see where you have anything in the code to make it shoot. I had a little trouble making it fly with the controls configured to use a joystick and the keyboard at the same time. I would suggest the following
1. (For now) make the input one way or the other or perhaps make it dual. i.e. joystick left() and leftkey() do the same thing.
2. I would strongly suggest that you not use 'disable escapekey' until you are nearly finished with the program.
3. Use functions and organize your code
Here is something I put together quickly:
sync on : sync rate 60
sync
set display mode 640, 480, 16
hide mouse
`disable escapekey
autocam off
randomize timer()
set camera range 1,10000
global speed# as float : speed# = 5.0
global thrust# as float : thrust# = 5.0
global MissileDelay# as float : global TotalMissiles as integer : TotalMissiles = 5
dim Missile(TotalMissiles,5)
for i= 1 to TotalMissiles
missile(i,1) = 99 + i : ` object number
missile(i,2) = rgb(rnd(128) + 127,rnd(128) + 127,rnd(128) + 127) : ` color
missile(i,3) = 0 : ` status 0 = inactive 1 = moving
missile(i,4) = 8.0 : ` speed
missile(i,5) = 0 : ` move counter
next i
SetupMatrix()
MakeModels()
do
GetInPut()
move camera speed#
MoveMissiles()
Debug()
sync
loop
end
function GetInput()
if leftkey() = 1 then turn camera left 2
if rightkey() = 1 then turn camera right 2
if downkey() = 1 then pitch camera up 2
if upkey() = 1 then pitch camera down 2
if keystate(44) = 1 then roll camera left 2 : ` Z key
if keystate(45) = 1 then roll camera right 2 : ` X key
if controlkey () = 1 then thrust# = thrust# + .25 : if thrust# > 50.0 then thrust# = 50.0
if shiftkey () = 1 then thrust# = thrust# - .5 : if thrust# < 0.0 then thrust# = 0.0
if returnkey() = 1 : ` fire missile
if timer() > MissileDelay#
` see if a missile is available
avbl = 0
for i = 1 to 5
if missile(i,3) = 0 then avbl = i : exit
next i
if avbl > 0
obj = missile(avbl,1)
camx# = camera position x()
camy# = camera position y()
camz# = camera position z()
position object obj,camx#,camy#,camz#
set object to camera orientation obj
pitch object down obj,1
missile(avbl,3) = 1
show object Missile(avbl,1)
MissileDelay# = timer() + 150.0
endif
endif
endif
speed# = curvevalue(thrust#,speed#,25)
endfunction
function Debug()
text 50,1,str$(speed#)
x# = camera position x() : z# = camera position z()
y# = get ground height(1,x#,z#)
text 120,1,str$(y#)
endfunction
function SetupMatrix()
make matrix 1,10000,10000,50,50
randomize matrix 1, 50
update matrix 1
position camera rnd(5000.0) + 2000.0,200.0,rnd(5000.0) + 2000
rotate camera 0.0,0.0,0.0
endfunction
function MakeModels()
` make missiles
for m = 100 to (TotalMissiles + 99)
make object sphere m,5
color object m,(missile((m - 99),2))
hide object m
next m
endfunction
function MoveMissiles()
for i = 1 to TotalMissiles
` check status
if Missile(i,3) = 1
move object Missile(i,1),Missile(i,4)
Missile(i,5) = Missile(i,5) + 1
if Missile(i,5) > 100
` missile has gone too far
hide object Missile(i,1)
Missile(i,3) = 0
Missile(i,5) = 0
else
` check collision w/baddies
` check collision with planets, etc.
` check collision with matrix
endif
endif
next i
endfunction
The code makes up to five spheres to shoot from the camera's perspective (use [ENTER] to shoot). I still don't like the controls that much, but you can customise it the way you want. The Z key rolls left and the x key rolls right.
Hope this helps,
LBFN
So many games to code......so little time.