# Little help with as

**URL:** https://forum.kirupa.com/t/little-help-with-as/183317
**Category:** Uncategorized
**Created:** [March 25, 2006, 7:30pm UTC](https://forum.kirupa.com/t/little-help-with-as/183317 "2006-03-25T19:30:28Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![woopsedoo](https://avatars.discourse-cdn.com/v4/letter/w/a87d85/32.png) [@woopsedoo](https://forum.kirupa.com/u/woopsedoo)
#### Post date: [March 25, 2006, 7:30pm UTC](https://forum.kirupa.com/t/little-help-with-as/183317/1 "2006-03-25T19:30:28Z")

</div>

can someone please give me a simple as code to have an mc (man) rotate to where the mouse is and when (MouseDown) occurs make a bullet mc (ball) fire in the direction that the man is facing because every code i make will not fire in the direction, it goes off at weird angles im not quite sure how to calculate the direction for it to move fowards

any help is apreciated

thanks  
woopsedoo:sen:

---

<div class="post-metadata">

### Author: ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)
#### Post date: [March 25, 2006, 10:43pm UTC](https://forum.kirupa.com/t/little-help-with-as/183317/2 "2006-03-25T22:43:55Z")

</div>

A simple way is

```auto
bulletSpeed = 3;
man.onEnterFrame = function(){
this._rotation = Math.atan2(this._y-_ymouse, this._x-_xmouse)/180*Math.PI-180;
}
onMouseDown = function(){
bulletMC.duplicateMovieClip("bullet"+i++, i, {_rotation:man._rotation, onEnterFrame:function(){
this._x+=Math.sin(this._rotation/180*Math.PI)*bulletSpeed;
this._y-=Math.sin(this._rotation/180*Math.PI)*bulletSpeed;
}});
} 

```

May need a little tweaking, but Maths isn’t my forte, if it’s not right, let me know 😛

---

<div class="post-metadata">

### Author: ![woopsedoo](https://avatars.discourse-cdn.com/v4/letter/w/a87d85/32.png) [@woopsedoo](https://forum.kirupa.com/u/woopsedoo)
#### Post date: [March 26, 2006, 12:12pm UTC](https://forum.kirupa.com/t/little-help-with-as/183317/3 "2006-03-26T12:12:54Z")

</div>

thanks a lot:hugegrin: :hugegrin: :hugegrin: :hugegrin: :hugegrin: :hugegrin: :hugegrin:

---

<div class="post-metadata">

### Author: ![woopsedoo](https://avatars.discourse-cdn.com/v4/letter/w/a87d85/32.png) [@woopsedoo](https://forum.kirupa.com/u/woopsedoo)
#### Post date: [March 26, 2006, 12:18pm UTC](https://forum.kirupa.com/t/little-help-with-as/183317/4 "2006-03-26T12:18:51Z")

</div>

sorry but the code or the man rotatingi didnt actualy nee but im afraid the code you gave me about the bullet dosnt work

---

<div class="post-metadata">

### Author: ![woopsedoo](https://avatars.discourse-cdn.com/v4/letter/w/a87d85/32.png) [@woopsedoo](https://forum.kirupa.com/u/woopsedoo)
#### Post date: [March 26, 2006, 12:29pm UTC](https://forum.kirupa.com/t/little-help-with-as/183317/5 "2006-03-26T12:29:41Z")

</div>

can anyone please help

---

<div class="post-metadata">

### Author: ![woopsedoo](https://avatars.discourse-cdn.com/v4/letter/w/a87d85/32.png) [@woopsedoo](https://forum.kirupa.com/u/woopsedoo)
#### Post date: [March 26, 2006, 12:38pm UTC](https://forum.kirupa.com/t/little-help-with-as/183317/6 "2006-03-26T12:38:50Z")

</div>

ive changed the code but it still isnt working can anyone correct me on

```auto

bs = 3;
Key.SPACE.onKeyDown = function() {
 bullety.duplicateMovieClip("bullet"+i++, i, {onEnterFrame:function () {
  this._x = _root.man._x;
  this._y = _root.man._y;
  this._x += Math.sin(this._rotation/180*Math.PI)*bs;
  this._y -= Math.sin(this._rotation/180*Math.PI)*bs;
 }});
};

```
