Ok. with the game im making (which is birds-eye view) , ive been using trigonometry to get the path that my bullets should travel (obviously). they move just fine until you move the cursor(crosshair), which then you start to control thier path, that is because of this.
my code goes like this.
function UpdateBullet() {
var xa;
var ya;
xa = 5*Math.acos(Math.atan(disty/distx));
ya = 5*Math.asin(Math.atan(disty/distx));
if(distx<0 && disty<0){
xa*=-1;
ya*=-1;
}else if(distx<0 && disty>0){
xa*=-1;
ya*=-1;
}
bullets._x += xa;
bullets._y += ya;
}
Where, bullets = _root[“bullet” + i]; (i comes from a for loop in InitBullet function ealrier in code)
as you can see the variables ‘disty’ and ‘distx’ in
xa = 5Math.acos(Math.atan(disty/distx));
ya = 5Math.asin(Math.atan(disty/distx));
they are the distance between the player and the crosshair but are in constant change, when you move the mouse.
What i want to know is what will be the easest way to get the values of disty and distx and store them as a constant value so they can be called back to use for the same bullets path??
N.B! You can shoot more then 1 bullet at a time, hence why i want to store multiple copies of disty, and distx.
i have thought of using a multi-dimension Array(for x and y) but cant find a good way of blending it with my code.
Help plz anyone.