# Bullet handling problem

**URL:** <https://forum.kirupa.com/t/bullet-handling-problem/226618>\
**Category:** Uncategorized\
**Created:** [May 22, 2007, 6:26pm UTC](https://forum.kirupa.com/t/bullet-handling-problem/226618 "2007-05-22T18:26:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![suvenier](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@suvenier](https://forum.kirupa.com/u/suvenier)\
**Post date:** [May 22, 2007, 6:26pm UTC](https://forum.kirupa.com/t/bullet-handling-problem/226618/1 "2007-05-22T18:26:53Z")

</div>

hI,

I have a problem in my games’s code.  
As it is a space game, the user controls a ship and fires bullets.  
So, every time you fire a bullet:

```auto

  if (Key.isDown(Key.SPACE) && okShoot) {
  okShoot = false;
  var newDepth = depth++;
  var name = "bullet_"+newDepth;
  var clip = _root.attachMovie("bullet", name, newDepth);
  clip._x = ship._x;
  clip._y = ship._y;
 
//(plus rest of the code that enables the bullet to move)
 
}
 

```

its ok for now(this code works well).

But when I need to check if that bullet has collided with a target(wich is random generated each time you change level), i can´t get the bullets name to pass to the colision function(because I may have already fired hundreds of bullets).  
I don´t want to use a “FOR LOOP”, because it slows down the game when you have already fired a lot of bullets.

does any one knows a better way for correcting this code?

thanks for reading.:book:
