Greetings everyone!
I’m making a small game prototype that resembles the old “Smash TV” arcade classic (or Robotron)…
I have the player moving around using the arrow keys and he is able to aim around the stage independent of the direction he is moving. Aiming is done using the mouse and he can fire and all… The shots he fires goes out ind the direction he’s facing and all is well - until I fire a second shot! Then any previous shots change the direction to match that of the new shot.
The reason for this is naturally that I grabbed the direction of the player at the time of a shot being fired and then I stored that information in to variables called xValue and yValue. These variables are given new information every time a new shot is fired and then I get this “redirecting” of previous shots. What is the best solution to this? Should I give each shot a unique variable set of its own? And if so, how would I express that in actionscript? Or is the solution something entirely different?
Here’s the shooting part of my game script:
_root.onMouseDown = function() {
i++;
var newname = “bullet”+i;
var newX = “xValue”+i;
var newY = “yValue”+i;
_root.attachMovie(“playerBullet”, newname, i100);
_root[newname]._y = _root.player._y;
_root[newname]._x = _root.player._x;
xValue = (Math.cos(Math.PI/180(_root.player._rotation-90))10);
yValue = (Math.sin(Math.PI/180(_root.player._rotation-90))*10);
_root[newname].onEnterFrame = function() {
this._x += xValue;
this._y += yValue;
/var tester = this._name;
trace(tester);
_root[newname]._x += (Math.cos(Math.PI/180_root.player._rotation)15)
_root[newname]._y += (Math.sin(Math.PI/180_root.player._rotation)15)/
if (this._x>555) {
this.removeMovieClip();
}
};
};
Thanks in advance to anyone who might be able to shed some light on this!