# \[fmx2004\]Trigonomic Shooting

**URL:** <https://forum.kirupa.com/t/fmx2004-trigonomic-shooting/101246>\
**Category:** Uncategorized\
**Created:** [February 7, 2004, 5:42pm UTC](https://forum.kirupa.com/t/fmx2004-trigonomic-shooting/101246 "2004-02-07T17:42:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![InsaneMonk](https://avatars.discourse-cdn.com/v4/letter/i/ce7236/32.png) [@InsaneMonk](https://forum.kirupa.com/u/InsaneMonk)\
**Post date:** [February 7, 2004, 5:42pm UTC](https://forum.kirupa.com/t/fmx2004-trigonomic-shooting/101246/1 "2004-02-07T17:42:35Z")

</div>

Hi, I am currently making a game in which you are in an overhead view. You can rotate, and I need to be able to shoot in w/e direction you are facing. I have a code, and when I shoot, it does shoot in the direction you are facing, but If you change direction, the bullet also changes direction. I know why, and I need desperate help. Here is the code:

In the frame:  
[AS]onLoad = function () {  
i = 1;  
bullet.\_visible = false;  
};  
onEnterFrame = function () {  
x = Math.cos(sqr.\_rotation\*Math.PI/180)_5;  
y = Math.sin(sqr.\_rotation_Math.PI/180)\*5;  
if (Key.isDown(Key.UP)) {  
sqr.\_rotation += 5;  
}  
if (Key.isDown(Key.DOWN)) {  
sqr.\_rotation -= 5;  
}  
if (Key.isDown(Key.SPACE)) {  
bullet.duplicateMovieClip(“obj”+i, i);  
this[“obj”+i].\_visible = true;  
i++;  
}  
};[/AS]

In the bullet:

[AS]onClipEvent (load) {  
this.\_x = sqr.\_x;  
this.\_y = sqr.\_y;  
}  
onClipEvent (enterFrame) {  
this.\_x += \_root.x;  
this.\_y += \_root.y;  
}[/AS]

here is the .fla:
