# Star fighter game

**URL:** https://forum.kirupa.com/t/star-fighter-game/184869
**Category:** Uncategorized
**Created:** [April 8, 2006, 5:42pm UTC](https://forum.kirupa.com/t/star-fighter-game/184869 "2006-04-08T17:42:11Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![roll4life](https://avatars.discourse-cdn.com/v4/letter/r/ecc23a/32.png) [@roll4life](https://forum.kirupa.com/u/roll4life)
#### Post date: [April 8, 2006, 5:42pm UTC](https://forum.kirupa.com/t/star-fighter-game/184869/1 "2006-04-08T17:42:11Z")

</div>

hi kirupa-folk,

a friend of mine and me are together working on a kinda “star fighter” game in flash. you know, you’ve your space-ship and you’re flying through a level and trying to destroy as much enemy-ships as your fingers let you

i got to a point, where i may not be able to get further without some help of you experts 🙂

_my problem:_  
in the level you are flying through with your space-ship is a number of \*\*n \*\*enemy-space-ships. you’re able to fire bullets from your own space-ship, which should hit the other enemy-space-ships to destroy them.

so far, so good, but how can i discover, which bullet hits which enemy-space-ship? here is my code-snippet:

```
 ActionScript Code:
 [FONT=Courier New][LEFT][COLOR=#0000ff]if[/COLOR][COLOR=#000000]([/COLOR] [COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]hitTest[/COLOR][COLOR=#000000]([/COLOR]level1_MC[COLOR=#000000][[/COLOR][COLOR=#ff0000]"enemy_MC"[/COLOR] + i[COLOR=#000000]][/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR][INDENT] removeMovieClip[COLOR=#000000]([/COLOR][COLOR=#0000ff]this[/COLOR][COLOR=#000000])[/COLOR];

```

[/INDENT][INDENT] level1\_MC[COLOR=#000000][[/COLOR][COLOR=#ff0000]“enemy\_MC”[/COLOR] + i[COLOR=#000000]][/COLOR].[COLOR=#0000ff]\_visible[/COLOR] = [COLOR=#000000] **false** [/COLOR]; [COLOR=#808080]_// replace with removeMovieClip();_[/COLOR]  
[/INDENT][INDENT] delete [COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]onEnterFrame[/COLOR];  
[/INDENT][COLOR=#000000]}[/COLOR]  
[/LEFT]  
[/FONT]

ok, this code-snippet is nested in an onEnterFrame-statement…the **variable i** is incremented every time, a new bullet is fired off. understandably, with this code i’m just able to discover whether a bullet hits **one specific enemy-ship** , but i’ve to check, if a single bullet hits all enemy-space-ships in the entire level, and if this happened, then the enemy-space-ship, which was hitted should be destroyed…

i hope, you know what i mean, sry for my terrible english! :ne:

maybe some of you, can help me out in a theoretical approach, would be very very cool…!!!

---

<div class="post-metadata">

### Author: ![Joppe](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@Joppe](https://forum.kirupa.com/u/Joppe)
#### Post date: [April 8, 2006, 10:45pm UTC](https://forum.kirupa.com/t/star-fighter-game/184869/2 "2006-04-08T22:45:42Z")

</div>

Not that I know the practical code I would think in the lines of an For loop. That every frame checks if the bullet hits ship one, two , three. like

```auto

for( var n = i; n <= numberOfEnemies; n++){
if( this.hitTest(level1_MC["enemy_MC" + n]) ) {

    removeMovieClip(this);

    level1_MC["enemy_MC" + n]._visible = false; // replace with removeMovieClip();

    delete this.onEnterFrame;

}
}

```

or something like that 😕

---

<div class="post-metadata">

### Author: ![roll4life](https://avatars.discourse-cdn.com/v4/letter/r/ecc23a/32.png) [@roll4life](https://forum.kirupa.com/u/roll4life)
#### Post date: [April 9, 2006, 8:14am UTC](https://forum.kirupa.com/t/star-fighter-game/184869/3 "2006-04-09T08:14:40Z")

</div>

hey joppe,

haha…you’re the man!!! it works perfect!!!

haha, the funny thing is, that i also thought of a for-loop possibility,  
but with my version of the for-loop, i created an endless one by mistake  
and my pc hung up…hahaha

but thx, anyway!!! i’m loving Kirupa from day to day more…:beam:

---

<div class="post-metadata">

### Author: ![Joppe](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@Joppe](https://forum.kirupa.com/u/Joppe)
#### Post date: [April 9, 2006, 8:37am UTC](https://forum.kirupa.com/t/star-fighter-game/184869/4 "2006-04-09T08:37:28Z")

</div>

Thats great 🙂
