# How to make clip go forward in a direction? [SOLVED]

I’m making a game with tank controls so I need the player to turn and move in a direction

I already got the turning done but I have no idea how to make the player move.

I just need the equation to do so.

any help?

EDIT: to clarify, I mean moving forward in the direction the clip is facing

use update and check for key down like so

``````if(keyIsDown("d")){
this.x += 100/project.framerate // right
}``````

i meant moving the the direction the clip is facing, not moving on an axis

thats not necessarily possible without using axises but

``````this.x += this.scaleX * (100/project.framerate)
``````

so say if its -1 it would move back and if its 1 it would move forward

no as in tank controls.

like you turn and face the direction you want to go forward in.

do you even know what tank controls are?

``````this.x += Math.cos(angle) * speed;
this.y += Math.sin(angle) * speed;
``````

Angle is in radians. To convert degrees to radians you use `deg / 180 * Math.PI`

thank you! this is exactly what i needed!

Sorry I had a similar goal and am still struggling to make the object move in the direction its facing. Mine just spins left/right but move in a set direction according to the radians chosen. Where exactly would the
this.x += Math.cos(angle) * speed;
this.y += Math.sin(angle) * speed;

be placed in the code?

after the forward/backward movement

hmm, i still cant get it to work but thank you for your help!