# Character movement and shoot not working

**URL:** <https://forum.kirupa.com/t/character-movement-and-shoot-not-working/299641>\
**Category:** flash\
**Created:** [November 8, 2009, 11:01pm UTC](https://forum.kirupa.com/t/character-movement-and-shoot-not-working/299641 "2009-11-08T23:01:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jorhfm](https://avatars.discourse-cdn.com/v4/letter/j/45deac/32.png) [@Jorhfm](https://forum.kirupa.com/u/Jorhfm)\
**Post date:** [November 8, 2009, 11:01pm UTC](https://forum.kirupa.com/t/character-movement-and-shoot-not-working/299641/1 "2009-11-08T23:01:10Z")

</div>

Hi all ^^  
I’m doing a simple game where you move the character using the arrow keys and shoot using the Mouse. The character rotates based on the Mouse angle.

I have two problems: when I move the character, he moves once, then stops then moves again as normal.  
My other problem is that when I click over a MovieClip, the bullet goes to the wrong angle.

My moving function:

```auto
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyHandler);

function keyHandler(event:KeyboardEvent):void {

            if (event.keyCode == 37) {
                jog.x=jog.x-pla.speed;
            }
            if (event.keyCode == 39) {
                jog.x=jog.x+pla.speed;
            }
            if (event.keyCode == 38) {
                jog.y=jog.y-pla.speed;
            }
            if (event.keyCode == 40) {
                jog.y=jog.y+pla.speed
            }
}

```

jog is the Instance Name of my movieclip. I have a class were the speed is inside. It’s instance is pla.

I have a class that makes my bullet move, and a function on my main timeline to put the bullet on the stage.

The function:

```auto
stage.addEventListener(MouseEvent.MOUSE_DOWN, atira);

function atira(event:MouseEvent):void {
    var newBullet:Bullet = new Bullet();
    newBullet.x=jog.x;
    newBullet.y=jog.y;

    addChild(newBullet);
    newBullet.trata_Tiro(event);

}

```

And here is my code to make it move and get the angle:

```auto
public function Bullet() {
            addEventListener(Event.ADDED, beginClass);
            
            addEventListener(Event.ENTER_FRAME, eFrame);
        }
        private function beginClass(event:Event):void {
            _root = MovieClip(root);
        }
        private function eFrame(event:Event):void {
                        
            y += speed*Math.sin(_angle)*speed;
            x += speed*Math.cos(_angle)*speed;
                    
        }
        
        public function trata_Tiro(event:Event) {
            _angle = Math.atan2(mouseY-event.target.y, mouseX-event.target.x);
        }
    }

```

Thanks for all the help =)
