| enemyTime ++;//incrementing time for enemy |
| if(enemyTime == enemyLimit){//if enough time has elapsed |
| | _root.attachMovie('mcEnemy', 'en'+enemyTotal,_root.getNextHighestDepth());//then add the enemy |
| | //setting it's coordinates |
| | _root['en'+enemyTotal]._x = int(Math.random()*Stage.width);//randomly within the boundaries |
| | _root['en'+enemyTotal]._y = -50; //sets this offstage at first |
| | _root['en'+enemyTotal].onEnterFrame = function(){//then give it some functions |
| | | this._y += 5; |
| | | |
| | | | enemyTime ++;//incrementing time for enemy |
| if(enemyTime == enemyLimit){//if enough time has elapsed |
| | _root.attachMovie('mcEnemy2', 'en'+enemyTotal,_root.getNextHighestDepth());//then add the enemy |
| | //setting it's coordinates |
| | _root['en'+enemyTotal]._x = int(Math.random()*Stage.width);//randomly within the boundaries |
| | _root['en'+enemyTotal]._y = -50; //sets this offstage at first |
| | _root['en'+enemyTotal].onEnterFrame = function(){//then give it some functions |
| | | this._y += 5; |
| | | |
| | | | //run a loop checking if it's touching any bullets |
| | | for(var cBullet:String in _root.bulletHolder){ |
| | | | //if it's touching the bullet |
| | | | //we have to use coordinates because hit testing doesn't seem to work |
| | | | if(this._y >= _root.bulletHolder[cBullet]._y-30 && this._y <= _root.bulletHolder[cBullet]._y){ |
| | | | | if(this._x <= _root.bulletHolder[cBullet]._x+5 && this._x >= _root.bulletHolder[cBullet]._x -35){ |
| | | | | | //then destroy this guy |
| | | | | | this.removeMovieClip(); |
| | | | | | //and destroy the bullet |
| | | | | | _root.bulletHolder[cBullet].removeMovieClip(); |
| | | | | | |
| | | | | | //up the score |
| | | | | | _root.score += 5; |
| | | | | } |
| | | | } |
| | | } |
| | | |
| | | //hit testing with the user |
| | | if(this.hitTest(_root.mcMain)){ |
| | | | //set the game to be over and go to lose screen |
| | | | gameOver = true; |
| | | | gotoAndStop('lose'); |
| | | | //and remove main |
| | | | mcMain.removeMovieClip(); |
| | | } |
| | | |
| | | //checking if the game is over or it's off the stage |
| | | if(gameOver || this._y > 450){ |
| | | | //destroy this guy if the game is over |
| | | | this.removeMovieClip(); |
| | | } |