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 328727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:31:20+00:00 2026-05-12T09:31:20+00:00

Im making a 2D game where the player controls a tank. I can make

  • 0

Im making a 2D game where the player controls a tank.

I can make the tank, and all, but whats really messing with my mind is how to make it rotate accordingly.

I want it to behave just like the Wii game, Tanks.
Fixed directions, and with no real front and back on the tank.

Driving up, then left should make it rotate to the left.
Driving up, then down should not make it rotate, just drive the other direction.

I red a tutorial a while back about some way to do that by dividing the degrees into 2 180 degree parts. But i have simply not been able to find that damn site again.

I hope you guys are able to understand what im trying to say.
Thanks in advance 🙂

  • 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-05-12T09:31:20+00:00Added an answer on May 12, 2026 at 9:31 am

    I think what you’re looking for is simply the best way to minimize the rotation of the tank, modulo 180 degrees.

    I would use the angle between the desired movement direction and the tank’s current direction to start. Make sure this is the minimum angle, then compare that with the angle between the tank’s current direction + 180 degrees. Something like:

    // smallest angle between the current direction and the desired direction
    minAngle1 = Math.Abs(Math.Min(tankAngle - desiredAngle, desiredAngle - tankAngle));
    
    // smallest angle between the opposite direction and the desired direction
    oppositeAngle = (tankAngle + 180) % 360;
    minAngle2 = Math.Abs(Math.Min(oppositeAngle - desiredAngle, desiredAngle - oppositeAngle));
    
    // get the smaller of two to rotate to
    if (minAngle1 < minAngle2)  {
      // we know that we should rotate the current direction to the desired direction
    } else {
      // rotate the opposing direction to the desired direction
    }
    

    Note you’ll need to play with your rotation signs to ensure you’re rotating the right way. Also, I’ve assumed you know your rotation angles, if you have vectors you can simplify this a little bit by using the dot product between the two vectors instead of the angle for comparisons.

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

Sidebar

Related Questions

I'm making a simple 2 player game in XNA and started looking into saving
I'm making a 2 player game where you play on either side of the
I'm making a game. Now if my player goes to another level the music
I'm making a game where the player is an upright capped cylinder, and the
I'm making flash game, and I have the staged masked so your character can
I am making a game in JAVA where I want to come up with
With regards to making a game server, it seems Erlang always comes up as
I'd like to rank a collection of landscape images by making a game whereby
I am making a simple game in order to learn a new language. I
I'm thinking about making a networked game. I'm a little new to this, and

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.