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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:02:57+00:00 2026-06-15T11:02:57+00:00

So I am currently working on learning slick. I was doing fine until I

  • 0

So I am currently working on learning slick. I was doing fine until I ran into a problem. I have been trying to find a answer for a good hour and could not. So I decided to post it on here.

My Problem: I have player on a 800 X 800 Grid. I am trying to make the player move to a certain point on the grid in a straight line. Now I can make him move on the X then turn and move on the Y, But I want to make him get there as fast as possible. So I figured if I could make a right triangle from the following points (Player pos, Target Pos, and the X,Y intercept see my image bellow).

My code:
Adj = (int) (TargetX-x); // Get The size of the Adjacent leg.
Opp =   (int) (TargetY-y); // Get the size of the Opposite leg.
OppAdj = Opp/Adj;          //Inverse tan is Opposite/Adjacent
TargetAngle =  Math.abs(Math.atan(Opp/Adj)*100);  //Keep the angle positive, and use inverse tan to get the missing angle.

Now what I thought this would do, is solve for the missing angle so I could rotate the player by that amount so the player can move in a straight line and hit the objective.

What this ends up doing though is is giving me a target angle of 73 degrees and a the Variable OppAdj ends up being 1.0.

What is wrong with my code?

Any help is appreciated!

Thanks,
Kyle

  • 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-15T11:02:57+00:00Added an answer on June 15, 2026 at 11:02 am
    OppAdj = Opp/Adj;
    

    That is the problem. You should do this:

    OppAdj = (double)(Opp)/Adj;
    

    That way it will give you a double for accuracy. By the way:

    TargetAngle =  Math.abs(Math.atan(Opp/Adj)*100);
    

    Should be:

    TargetAngle =  Math.abs(Math.atan(OppAdj)*100);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to C# and have been working on learning database's. Currently I'm trying
I've been recently working towards learning a bit of assembly and I'm currently stumped
I am learning TDD and I currently have a method that is working but
Working on learning Django, and at the moment (trying to) have a template that
I'm currently working on a Rails project right now, doing learning and working on
I am currently working on famous Mountain Car problem from reinforcement learning. This problem
I'm currently working on a semantic web e-learning project. I've made an ontology and
I'm currently reading Learning Rails 3. I'm working on an example where you can
Currently working with converting SQLException error messages into messages that are more useful for
I'm currently working on learning some game development with Java. I'm working on the

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.