PDA

View Full Version : Bullets in game are Misbehaving.


RedHotFunk
05-29-2008, 03:32 AM
Bare with me, I'm quite a noob when it comes to flash actionscript, but here I go:

I have my main time line, where I have two important movie clips. One of the object firing objects, and another movie clip which is being fired (turret and bullet for the sake of my question). So I have embedded script within the movie clip for the turret:

Turret Movie Clip
onClipEvent (load) {
lastangle = 0;
curbullet = 0;
this.level=999999
}

onClipEvent (enterFrame) {

curx = this._x;
cury = this._y;

xposition = _root._xmouse-curx;
yposition = _root._ymouse-cury;
anglez = Math.atan2(yposition, xposition)*(180/Math.PI);
at

this._rotation = Math.round(anglez);

onMouseDown = function () {
duplicateMovieClip(_root.bullet_mc, "bullet"+curbullet+"_mc", curbullet);
curbullet++;

};

As I shoot my bullet, I duplicate the movie clip, give it a new level and then it goes into my original movieclip of the bullet, and the duplicate movie clips then proceed to follow the script within the movieclip... or so they should :(



Bullet Movie Clip
onClipEvent (load) {

curx = _root.face_mc._x;
cury = _root.face_mc._y;;

xposition = _root._xmouse-curx;
yposition = _root._ymouse-cury;

anglez = Math.atan2(yposition, xposition)*(180/Math.PI);

xx=Math.round(Math.cos(anglez)*10);
yy=Math.round(Math.sin(anglez)*10);

this._x = _root.face_mc._x;
this._y = _root.face_mc._y;
}

onClipEvent (enterFrame) {

this._x += xx;
this._y += yy;
_root.angle_txt = angle2;

}

As I shoot the bullet, the angles go in weird directions.
Does anyone know why, or have a suggestion on what I can do? Mind you, I want to keep the bullets at a constant speed as well. All help appreciated, much thanks :)