Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8905015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:17:04+00:00 2026-06-15T02:17:04+00:00

I want to move an object forward, depending on what angle it faces, in

  • 0

I want to move an object forward, depending on what angle it faces, in this case it’s a tank.
So what I want to do is this:
When I press W, the tank has to move forward.
When I press A or D, it rotates the angle.

So far I’m able to rotate the angle but I have no idea on how to make the tank move forward.
I have tried things like.

if (key.IsKeyDown(Keys.W))
{
    TankPos.Y = TankPos.Y - 4;
}

But of course, that only makes it go up, no matter the angle. Any simple solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:17:05+00:00Added an answer on June 15, 2026 at 2:17 am

    Elaborating on spenders answer, and depending if you are using fixed time step or not, you also need to multiply the delta with the time elapsed since the last frame.

    var deltaX = Math.Sin(angleRad) * tankSpeed * gameTime.ElapsedGameTime.Milliseconds;
    var deltaY = -Math.Cos(angleRad) * tankSpeed * gameTime.ElapsedGameTime.Milliseconds;
    

    (Milliseconds or Seconds, depending on which measurement you use for your tank speeds.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My problem is that I have an object I want to move forward in
I am using the IPhone's Accelerometer to make a object move. I want to
I have several objects like this: I want to move type and value one
I want to move to the next control when I press the Enter key
i want move up the object, delay 1000ms , then hide it, i get
I want to move an object to a specific point on the screen. (Specifically,
Quite often, I'll want to move an object along by 2 points, so I'll
I want to move a Graphics object towards the cursor when the user clicks
When I press any of the following keys, the object that I want to
Here I want to move some cocos2D sprite object from top to bottom. Sprites

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.