Desperate for help - can't let this defeat me

I’ve been trying to figure this out for a very long time now and as you can see I still haven’t…

first… here’s a link to the first part
http://www.bgidesign.com/flashgames/shooting.html

pretty simple… rocks flying through space… if they touch your ship you’re dead… onPress fires a shot… if your shot hits one of the rocks something happens.

now the problem is…

It’s easy to detect when a “ROCK” hits the “SHIP” because the ship is one object and can be done with collision detection using hitTest method inside the “ROCK” movie clip…

but as I mentioned I want to see if my shots hit one of the rocks… and here’s the big BUT…
all my rocks are randomly generated like this:
duplicateMovieClip(_root.star, “star”+i, i);
duplicateMovieClip(_root.star2,“star2”+i,i+1);

where “star” and “star2” are just ugly circles converted to MovieClips and named that.

this is where the problem occurs… if I was to check for collision detection between a “BULLET” and “STAR” or “STAR2” I would only be able to do it for the initial movie clip and not the duplicated ones because their name changes as they are duplicated and become star200…star201…star202 etc…

I have tried a LOT of things but I don’t seem to be able to figure out a programmatic way of working around this…

I would really appreciate your help even if it’s just a thought… maybe it’s something small that I could do different and make it work

just for reference here is the code… maybe it will help you help me… hehe

Main Timeline Frame 1
Mouse.hide();
startDrag(_root.shooter, true);

SHIP - referred to as “shooter” in the code
on (release) {
_root.fire = 1;
_root.i += 1;
duplicateMovieClip(_root.bullet, “bullet”+i, i);
}

BULLET
onClipEvent (load) {
this._visible = 0;
if (_root.fire == 1) {
this._x = _root.shooter._x;
this._y = _root.shooter._y;
}
z=0;
zspeed=0.9;
fl=10;
}

onClipEvent (enterFrame) {
if (this != _level0.bullet) {
if (_root.fire == 1) {
this._y -= 10;
this._visible = 1;
}
if (this._y<0) {
this.removeMovieClip();
}
}
scale=fl/(fl+z);
_xscale=_yscale=100*scale;
z+=zspeed;
}

STAR
onClipEvent (load) {
this._x = Math.random()*680 + 10;
this._y = 0;
z=0;
zspeed=1;
fl=100;
}
onClipEvent (enterFrame) {
if (!_root.dead){
if (this.hitTest(_root.shooter)) {
xd = _root.shooter._x;
xy = _root.shooter._y;
_root.hit._x = _root._xmouse;
_root.hit._y = _root._ymouse;
_root.hit._visible = true;
_root.hit.gotoAndPlay(2);
Mouse.show();
_root.shooter._visible = false;
_root.dead = true;
}
}

	this._y += 5 - (_root._ymouse/500);
	if (this != _level0.star) {
	if (this._y&gt;520) {
		this.removeMovieClip();			
	}
	}
scale=fl/(fl+z);

_xscale=_yscale=1000*scale;
z+=zspeed;

}

CONTROLLER / DUPLICATOR
onClipEvent(enterFrame) {
i+=1;
j+=1;
if (j/5 == 5) {
duplicateMovieClip(_root.star, “star”+i, i);
duplicateMovieClip(_root.star2, “star2”+i, i+1);
j = 0;
}
}

Thank you kindly in advance

thank you… that seems like a great link… hopefully i’ll be able to find what I want on it.

i’m guessing you deleted your post cause I sure don’t see it anymore…heheheh

hmm… here is some pseudo code for you
untested but maybe it will help

if (this._droptarget.indexOf(“rock”)!=-1)
telltarget(this._droptarget){gotoAndPlay(“explode”);}

it does use deprecated features of flash though

(_droptarget is a string, so you have to use telltarget to get at the object)

its a challenge to comeup with alternatives to hitTesting every rock, every frame (CPU nightmare).

i changed my mind because it wasnt the link i thought it was
but it is a great page

thanks again… i’ll try your example and read the site

Here’s a thought, have each rock add it’s name to an array, then have each bullet hittest against the array. but i’m not quite sure where to go from there.

that’s something I thought about but as clownstaples said this will still need to be done every frame to detect collision… and considering it’s 40fr/sec and I have to loop through the whole array of current rocks it will still be a CPU nightmare :)…

but I’ll try it later on and let you guys know how it went.

thank you for trying to help