Question
Controlling fire in Space Invaders game
Hi again,
still working through the tutorial on Space Invaders in Flash MX 2004 (bit out of date, I know).
I've got the player craft under mouse control. What I don't like about the game is that you can fire as rapidly as you wan't, though the number of bullets is limited. You can change this limit in the variable - I would rather have it though that you can only have a set number of bullets in play at a time (at the moment, if you go over the limit, the uppermost bullets just disapear).
Here is the code:
// when the mouse cliks
onClipEvent(mouseDown)
{
// duplicate the bullet mc
_root.bullet.duplicateMovieClip("bullet"+bulletNum,bulletNum);
// set the coords to the mouse clik
eval("_root.bullet" + bulletNum)._x = this._x;
eval("_root.bullet" + bulletNum)._y = this._y;
// increment the bullet number
bulletNum++;
// if more than 50 bullets , start again at 0
if(bulletNum>50)
bulletNum = 0;
}
What code could I use to have it so that you can only have, say, 3 bullets in play at once, and you can't fire again until they've hit / left the screen?
regards,
g
still working through the tutorial on Space Invaders in Flash MX 2004 (bit out of date, I know).
I've got the player craft under mouse control. What I don't like about the game is that you can fire as rapidly as you wan't, though the number of bullets is limited. You can change this limit in the variable - I would rather have it though that you can only have a set number of bullets in play at a time (at the moment, if you go over the limit, the uppermost bullets just disapear).
Here is the code:
// when the mouse cliks
onClipEvent(mouseDown)
{
// duplicate the bullet mc
_root.bullet.duplicateMovieClip("bullet"+bulletNum,bulletNum);
// set the coords to the mouse clik
eval("_root.bullet" + bulletNum)._x = this._x;
eval("_root.bullet" + bulletNum)._y = this._y;
// increment the bullet number
bulletNum++;
// if more than 50 bullets , start again at 0
if(bulletNum>50)
bulletNum = 0;
}
What code could I use to have it so that you can only have, say, 3 bullets in play at once, and you can't fire again until they've hit / left the screen?
regards,
g