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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:24:33+00:00 2026-05-15T06:24:33+00:00

I am programming a game and I have come to a very hard spot.

  • 0

I am programming a game and I have come to a very hard spot. Basically I have a circle and I have 2 angles on this circle. Angle 1 (A) is a point I want angle 2 (B) to go to. During my game every frame I need to check weither or not to increase or decrease my angle value by a certain amount (speed) to eventually reach the first angle. My question is how do I do this?

I tried doing this but I don’t seem to be doing it right.

bool increase = false;

float B = [self radiansToDegrees:tankAngle];
float A = [self radiansToDegrees:tankDestinationAngle];
float newAngle = B;

if(B < A) {

    float C = B - (360 - A);
    float D = A - B;

    if(C < D) increase = false;
    else increase = true;

} else if(B > A) {

    float C = B - A;
    float D = A - (360 - B);

    if(C < D) increase = false;
    else increase = true;

}

if(increase) {
    newAngle += 1.0;
} else {
    newAngle -= 1.0;
}

if(newAngle > 360.0) {
    newAngle = 0 + (newAngle - 360.0);
} else if(newAngle < 0.0) {
    newAngle = 360 + newAngle;
}

if(newAngle == 0) newAngle = 360;

newAngle = [self degreesToRadians:newAngle];

[self setTanksProperPositionRotation:newAngle];

The basic effect I am trying to achieve is when the user makes a new point, which would be angle 1, angle 2 would move towards angle 1 choosing the fastest direction. I think I have spent around 4 hours trying to figure this out.

  • 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-15T06:24:34+00:00Added an answer on May 15, 2026 at 6:24 am

    Basically you want to check which angle gives you the smallest arc length (L).

    alt text

    alt text

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

Sidebar

Related Questions

With reference to this programming game I am currently building. I have a Class
I'm new to game programming. And i have a question. I want to have
I'm programming this game in OpenGL, mostly working inside an single EAGLView (I'm not
I want to get started game programming in C/C++, or C# with DirectX or
I want to study Cocos2d, seems it's a good framework for iPhone game programming.
So it has been a while since I have done any game programming in
I'm a beginner in game development and game programming. I have experience in computer
This question may have been asked before, but I'm starting to get into game
Support we have an n * m table, and two players play this game.
Cheers, I ran into this chunk of code in Programming Game AI by Example:

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.