First off, please use the edit button instead of making multiple posts. Secondly, when posting code on the forum, click the CODE button, copy and paste your code and then click the CODE button again.
I put together some basic code to try and help you with this, as I don't think what you have posted will work. Please bear in mind, you cannot simply plug this code into the editor and run it as is. It is a framework to help you and you will need to add your player object and stuff to it in order for it to work. I have added comments to the code to help you with it. If you have questions or need further assistance, please post them again.
sync on : sync rate 60
backdrop on : color backdrop 0
autocam off : hide mouse
randomize timer()
global TotalMissiles as integer : TotalMissiles = 29
global PlayerMissiles as integer : PlayerMissiles = 5
global Eng2Base as integer : Eng2Base = 20099
global PlayerObj as integer : PlayerObj = 100
global PlayerStat as integer : PlayerStat = 1
global PMissileDelay as integer : PmissileDelay = timer()
dim missile(TotalMissiles,5) : dim Pmissile(PlayerMissiles,5)
SetupMissiles()
repeat
MovePlayer()
MoveAIMissiles()
MovePlayerMissiles()
sync
until spacekey() = 1
show mouse
end
function SetupMissiles()
` set up AI missiles
for i = 1 to TotalMissiles
missile(i,1) = 10099 + i : ` object number
missile(i,2) = 0 : ` status = hidden ( 1= active)
missile(i,3) = rnd(2) + 1 : ` pick random color - (1 = white, 2 = red, 3 = green, etc.)
missile(i,4) = 3 : ` speed of missile
missiles(i,5) = 200 : ` counter / timer
make object plain missile(i,1),5,1
` color the missile
select missile(i,3)
case 1
color object missile(i,1),rgb(255,255,255) : set object ambience missile(i,1),rgb(255,255,255)
endcase
case 2
color object missile(i,1),rgb(255,0,0) : set object ambience missile(i,1),rgb(255,0,0)
endcase
case 3
color object missile(i,1),rgb(0,255,0) : set object ambience missile(i,1),rgb(0,255,0)
endcase
endselect
hide object missile(i,1)
next i
` set up player missiles
for i = 1 to PlayerMissiles
Pmissile(i,1) = 11999 + i : ` object #
Pmissile(i,2) = 0 : ` status = hidden (1 = active)
Pmissile(i,3) = 4 : ` blue
Pmissile(i,4) = 3 : ` speed of missile
make object plain Pmissile(i,1),5,1
color object Pmissile(i,1),rgb(0,0,255) : set object ambience Pmissile(i,1),rgb(0,0,255)
hide object Pmissile(i,1)
next i
endfunction
function MoveAIMissiles()
for i = 1 to TotalMissiles
if missile(i,2) = 1 : ` is missile active?
move object missile(i,1),missile(i,4)
` check collision against the player object
if PlayerStat = 1
if object collision(PlayerObj,missile(i,1) = 1
` AI shot player
hide object PlayerObj
` make explosion where player was
` restart
endif
endif
endif
next i
endfunction
function MovePlayer()
` get user input and move player object
` get user input and fire player missile
endfunction
function MovePlayerMissiles()
for i = 1 to PlayerMissiles
if Pmissile(i,2) = 1 : ` is it active
move object Pmissile(i,1),Pmissile(i,4)
` check collision with enemies
` check collision with enemy missiles
endif
next i
endfunction