# Goal = (racecar + mouse directional) + movement

**URL:** <https://forum.kirupa.com/t/goal-racecar-mouse-directional-movement/189394>\
**Category:** Uncategorized\
**Created:** [June 2, 2006, 5:03am UTC](https://forum.kirupa.com/t/goal-racecar-mouse-directional-movement/189394 "2006-06-02T05:03:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kpxnamja](https://avatars.discourse-cdn.com/v4/letter/k/7c8e57/32.png) [@kpxnamja](https://forum.kirupa.com/u/kpxnamja)\
**Post date:** [June 2, 2006, 5:03am UTC](https://forum.kirupa.com/t/goal-racecar-mouse-directional-movement/189394/1 "2006-06-02T05:03:47Z")

</div>

Hello, I’ve been working on a project where the upper body is controlled via the mouse, and the lower body down is controlled by the directional keys w,a,s,d. Here’s the dilema: I managed to get the w,a,s,d keys to work; however, it doesn’t act like a car. I wish to make the movement to go foward when “W” is pressed regardless if it points north,east,west,and south, etc. vise-versa with “s”. And for “a” and “d” move counter wise /clock wise

help is much appreciated.

And also as a bonus, it would be really nice if all my actionscript could be replaced from a clip event to a script, all done in one frame.

Thanks 😃

For those who hate to d/l fla’s

this is the clip event on the characters “body”

```php
onClipEvent (enterFrame) {
    x=this._xmouse;
    y=this._ymouse*-1;
    angle = Math.atan(y/x)/(Math.PI/180);
    if(x<0){angle+=180}
    if(x>=0&&y<0){angle+=360}
    _root.angletext=angle;
    _root.arrow._rotation=angle*-1;
    
//Basic movement
    if (Key.isDown(87)){
        _y -= _root.speed;
        _root.arrow._y -=_root.speed;  
    }
    if (Key.isDown(83)){
        _y += _root.speed;
        _root.arrow._y +=_root.speed;  
    }
    if (Key.isDown(65)){
        _x -= _root.speed;
        _root.arrow._x -=_root.speed;  
    }
    if (Key.isDown(68)){
        _x += _root.speed;
        _root.arrow._x +=_root.speed;  
    }
}

```
