# Enemy Initiation

**URL:** <https://forum.kirupa.com/t/enemy-initiation/218328>\
**Category:** programming\
**Created:** [March 6, 2007, 8:46pm UTC](https://forum.kirupa.com/t/enemy-initiation/218328 "2007-03-06T20:46:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Esoltas](https://avatars.discourse-cdn.com/v4/letter/e/5e9695/32.png) [@Esoltas](https://forum.kirupa.com/u/Esoltas)\
**Post date:** [March 6, 2007, 8:46pm UTC](https://forum.kirupa.com/t/enemy-initiation/218328/1 "2007-03-06T20:46:47Z")

</div>

First of all- Yes, i’ve tried using/modifying the Kirupa tutorial (on a vertical shooter) to suit my needs, but when I implemented the knowedge onto my game, 2 pieces appeared in close sequence, and then only one of them moved right along the x axis as it was supposed to for about 2 seconds, only then to stop and the other enemy (flags of nations) to disappear. Here’s my code on Frame 1.

var i;  
function fireBullets() {  
i++;  
var newname = “bullet”+i;  
\_root.attachMovie(“bullet”, newname, i);  
\_root[newname].\_y = \_root.hero.\_y-100;  
\_root[newname].\_x = \_root.hero.\_x;  
\_root[newname].onEnterFrame = function() {  
var bullet\_speed = 4;  
var alpha\_decrease = 3;  
this.\_y -= bullet\_speed;  
this.\_alpha -= alpha\_decrease;  
this.\_yscale -= alpha\_decrease;  
this.\_xscale -= alpha\_decrease;  
if (this.\_x\>555) {  
this.removeMovieClip();  
}  
};  
}  
var enemiesCurrent = 0;  
function makeFlags(){  
var enemyCount;  
var flagNo;  
var newflag = “newflag” + enemiesCurrent;  
\_root.onEnterFrame = function (){  
if (enemiesCurrent \< 1){  
\_root.attachMovie(“flag”, newflag, enemyCount);  
enemyCount +=1;  
\_root[newflag].\_currentframe = flagNo + 1;  
\_root[newflag].\_y = random(70);  
flagNo += 1;  
enemiesCurrent += 1;  
}  
if (newflag.\_x = 551){  
newflag.\_visible = false;  
enemiesCurrent -= 1;  
}  
_root[newflag]._ = 50;  
\_root[“newflag”+(enemiesCurrent - 1)].\_x += 10  
\_root[newflag].\_x += 10  
}  
};  
\_root.onEnterFrame = function() {  
moveHero(5);  
makeFlags();  
updateFlags(newflag);  
};  
If you would like to tinker with my flash directly, send me an email and I’ll send it to you. [esoltas@gmail.com](mailto:esoltas@gmail.com)
