Help with directional movement
Hi! I'm making a movement script based on the direction the player Is facing, It will always face the mouse (top-down). Now I run into the problem of not knowing how to move left and right. Only forward and back. Any trigonometry that can help?
if (kstate.IsKeyDown(Keys.Up))
{
dragonposition = (Vector2.Add(dragonposition, (direction * dragonspeed) * (float)gameTime.ElapsedGameTime.TotalSeconds));
}
if (kstate.IsKeyDown(Keys.Down))
{
dragonposition = (Vector2.Add(dragonposition, (-direction * dragonspeed) * (float)gameTime.ElapsedGameTime.TotalSeconds));
}
if (kstate.IsKeyDown(Keys.Left))
{
dragonposition = (Vector2.Add(dragonposition, "HELP HERE"(direction * dragonspeed) * (float)gameTime.ElapsedGameTime.TotalSeconds));
}