Right I have extracted some code from the game I am working on at the moment so you won't be able just to paste it in and hope it works, but you will be able to see how I do things. It might seem a little complicated but it isn't really. I have different bullet states (arrays) so I can do different things with the bullets E.G animate them on impact. I hope you can work out what you need to do based on my code.
If you want to see how my game is so far than click the link to take you to my page and download, so you can see if this is the way in which you want to progress. I still have alot of tweaking to do but you will get the idea of what I am trying to achieve.
http://217.210.154.125/CProject.htm
regards,
OzBot
_
dim rocketstate(6)
dim rocketlock(6)
dim bullet#(70,4)
dim bulletstate(70,4)
setup:
Rem at load time:
rem line for detecting hits
line=9
load object "media\line.x",laser
scale object line,14,14,1000
hide object line
SET OBJECT COLLISION TO POLYGONS line
Aim=27
make object plain aim,.01,.01
hide object aim
rem ship bullets
for i =131 to 200
load object "media\innerLaser.x",i
ghost object on i
scale object i,7,7,40
hide object i
next i
for i=201 to 270
load object "media\outerLaser.x",i
ghost object on i
scale object i,7,7,40
hide object i
rem SET OBJECT COLLISION TO POLYGONS i
next i
rem rockets for ship
for rocket=19 to 24
load object "media\rocket.x",rocket
scale object rocket,300,300,600
hide object rocket
next rocket
Return
Rem in main loop:
_ContolLine:
position object line, camera position x(),camera position y(),camera position z()
set object to camera orientation line
move object line,5000
return
_ControlShipShoot:
rem aim control for guding bullets and rockets that are not locked on to aq object
position object aim,camera position x(),camera position y(),camera position z()
set object to camera orientation aim
rem move object aim,112-int(fov#)
move object aim,80:pitch object up aim,90: move object aim,(fov#/61.9621*3)
gosub _Rockets
Gosub _Bullets
return
_Rockets:
if readyrocket<7
if disablemousebutton2>0 then dec disablemousebutton2,1
if disablemousebutton2=0
lockontext=0
rem rocket fire without lockon
If SPRITE VISIBLE(lockch)=0 and mouseclick()=2
rocketstate(readyrocket)=1
set object to object orientation readyrocket+18,ship
if autoaim=0 then point object readyrocket+18, object position x(aim),object position y(aim),object position z(aim)
rem if autoaim>0 then point object readyrocket+18, object position x(autoaim),object position y(autoaim),object position z(autoaim)
inc readyrocket,1
disablemousebutton2=75
endif
rem rocket fire with lock on
If SPRITE VISIBLE(lockch)=1 and mouseclick()=2
lockontext=1
lockdisplay=lockenemy
rocketstate(readyrocket)=2
rocketlock(readyrocket)=lockenemy
point object readyrocket+18,object position y(lockenemy),object position y(lockenemy),object position z(lockenemy)
inc readyrocket,1
disablemousebutton2=100
endif
endif
endif
for rocket=19 to 24
rem position with ship if state is Zero
if rocketstate(rocket-18)=0 and object visible(rocket)=1
position object rocket,object position x(ship),object position y(ship),object position z(ship)
set object to object orientation rocket,ship
if rocket=19
turn object left rocket,-90
pitch object up rocket,-25
move object rocket,.2
set object to object orientation rocket,ship
endif
if rocket=20
turn object left rocket,90
pitch object up rocket,-25
move object rocket,.2
set object to object orientation rocket,ship
endif
if rocket=21
turn object left rocket,-90
pitch object up rocket,-25
move object rocket,.16
set object to object orientation rocket,ship
endif
if rocket=22
turn object left rocket,90
pitch object up rocket,-25
move object rocket,.16
set object to object orientation rocket,ship
endif
if rocket=23
turn object left rocket,-90
pitch object up rocket,-25
move object rocket,.12
set object to object orientation rocket,ship
endif
if rocket=24
turn object left rocket,90
pitch object up rocket,-25
move object rocket,.12
set object to object orientation rocket,ship
endif
endif
rem move rocket if not guided
if rocketstate(rocket-18)=1 and object visible(rocket)=1
move object rocket,speed#+.35
endif
rem move rocket to object if guided
if rocketstate(rocket-18)=2 and object visible(rocket)=1
i=rocketlock(rocket-18)
ex#=object position x(i)
ey#=object position y(i)
ez#=object position z(i)
point object rocket,ex#,ey#,ez#
move object rocket,speed#+.35
endif
next rocket
return
_Bullets:
rem bullets
for i=131 to 200 step 2
if bulletstate(i-130,1)>1
bulletstate(i-130,2)=bulletstate(i-130,2)+15
bulletstate(i-130,3)=bulletstate(i-130,3)+15
bulletstate(i-130,4)= bulletstate(i-130,4)-5
scale object i, bulletstate(i-130,2)*.5, bulletstate(i-130,3)*.5, bulletstate(i-130,4)*.5
scale object i+70,bulletstate(i-130,2), bulletstate(i-130,3), bulletstate(i-130,4)
endif
if bulletstate(i+1-130,1)>1
bulletstate(i+1-130,2)=bulletstate(i+1-130,2)+15
bulletstate(i+1-130,3)=bulletstate(i+1-130,3)+15
bulletstate(i+1-130,4)= bulletstate(i+1-130,4)-5
scale object i+1,bulletstate(i+1-130,2)*.5,bulletstate(i+1-130,3)*.5,bulletstate(i+1-130,4)*.5
scale object i+71,bulletstate(i+1-130,2), bulletstate(i+1-130,3), bulletstate(i+1-130,4)
endif
if bulletstate(i-130,1)=1
scale object i,7,7,40
scale object i+70,7,7,40
hide object i
hide object i+70
endif
if bulletstate(i+1-130,1)=1
scale object i+1,7,7,40
scale object i+71,7,7,40
hide object i+1
hide object i+71
endif
if bulletstate(i-130,1)>0 then dec bulletstate(i-130,1),1
if bulletstate(i+1-130,1)>0 then dec bulletstate(i+1-130,1),1
if object visible(i)=1 and bulletstate(i-130,1)=0
move object i,speed#+1
move object i+70,speed#+1
endif
if object visible(i+1)=1 and bulletstate(i+1-130,1)=0
move object i+1,speed#+1
move object i+71,speed#+1
endif
if object visible(i)=1 and bulletstate(i-130,1)=0 or object visible(i+1)=1 and bulletstate(i+1-130,1)=0
gosub _AlienBullethit
bx#=bullet#(i-130,1)
by#=bullet#(i-130,2)
bz#=bullet#(i-130,3)
object2=i
gosub _Bdistance
if dst>shootdst then hide object i:hide object i+1:hide object i+70:hide object i+71:bulletstate(i-130,1)=0: bulletstate(i+1-130,1)=0
endif
next i
if shootimer>0 then dec shootimer,1
if shootcounter>200 then shootcounter=131
if mouseclick()=1 and object visible(shootcounter)=0 and shootimer=0 and bulletstate(i-130,1)=0
show object shootcounter
show object shootcounter+70
show object shootcounter+1
show object shootcounter+71
if object size x(shootcounter)>.028 then scale object shootcounter,7,7,40
if object size x(shootcounter+70)>.0342369 then scale object shootcounter+70,7,7,40
if object size x(shootcounter+1)>.028 then scale object shootcounter+1,7,7,70
if object size x(shootcounter+71)>.0342369 then scale object shootcounter+71,7,7,40
position object shootcounter,object position x(ship),object position y(ship),object position z(ship)
set object to object orientation shootcounter,ship
move object shootcounter,.7: rem how far forward bullet is from ship on initial fire display
turn object left shootcounter,-90
pitch object up shootcounter,-25
move object shootcounter,.17
if autoaim=0 then point object shootcounter,object position x(aim),object position y(aim),object position z(aim)
rem if autoaim>0 then point object shootcounter,object position x(autoaim),object position y(autoaim),object position z(autoaim)
move object shootcounter,-.08
position object shootcounter+70,object position x(ship),object position y(ship),object position z(ship)
set object to object orientation shootcounter+70,ship
move object shootcounter+70,.7
turn object left shootcounter+70,-90
pitch object up shootcounter+70,-25
move object shootcounter+70,.17
if autoaim=0 then point object shootcounter+70,object position x(aim),object position y(aim),object position z(aim)
rem if autoaim>0 then point object shootcounter+70,object position x(autoaim),object position y(autoaim),object position z(autoaim)
move object shootcounter+70,-.15
position object shootcounter+1,object position x(ship),object position y(ship),object position z(ship)
set object to object orientation shootcounter+1,ship
move object shootcounter+1,.7
turn object left shootcounter+1,90
pitch object up shootcounter+1,-25
move object shootcounter+1,.17
if autoaim=0 then point object shootcounter+1,object position x(aim),object position y(aim),object position z(aim)
rem if autoaim>0 then point object shootcounter+1,object position x(autoaim),object position y(autoaim),object position z(autoaim)
move object shootcounter+1,-.08
position object shootcounter+71,object position x(ship),object position y(ship),object position z(ship)
set object to object orientation shootcounter+71,ship
move object shootcounter+71,.7
turn object left shootcounter+71,90
pitch object up shootcounter+71,-25
move object shootcounter+71,.17
if autoaim=0 then point object shootcounter+71,object position x(aim),object position y(aim),object position z(aim)
rem if autoaim>0 then point object shootcounter+71,object position x(autoaim),object position y(autoaim),object position z(autoaim)
move object shootcounter+71,-.15
bullet#(Shootcounter-130,1)= object position x(Shootcounter)
bullet#(Shootcounter-130,2)= object position y(Shootcounter)
bullet#(Shootcounter-130,3)= object position z(Shootcounter)
inc shootcounter,+2
shootimer=2
endif
return
_hud1:
REM HUD Collsion Detection
if object visible (spikeship)=1
if object collision(spikeship,line)=1 then hud(spikeship)=1:lockenemy=spikeship
if object collision(spikeship,line)<1 then hud(spikeship)=0
hudcheck=hudcheck+hud(spikeship)
endif
return
_hud2:
Rem Set sprite to be displayed
hide sprite redch: show sprite greench: normalflight=1: avoidflight=0
if hudcheck=0 then lockon=0: If SPRITE VISIBLE(lockch)=1 then hide sprite lockch
if hudcheck>0 then hide sprite greench: show sprite redch: normalflight=0: avoidflight=1:inc lockon,1
hudcheck=0
if lockon=20 then show sprite lockch