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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:32:19+00:00 2026-06-08T04:32:19+00:00

I have two separate objects in Java, Object1 and Object2 , both are the

  • 0

I have two separate objects in Java, Object1 and Object2, both are the same size and square. For each object I can get the x and y coordinates. What I need to do is check if Object1 is within a certain distance of Object2. That distance is within 32 points on both the X and Y axis.

once the condition has been met then I can run my code. e.g.

    if ( check condition ) {
    //my code here
    }
  • 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-08T04:32:22+00:00Added an answer on June 8, 2026 at 4:32 am

    Try the following:

    if(Math.abs(Object1.x - Object2.x) <= 32 && Math.abs(Object1.y - Object2.y) <= 32)
    {
        // Do stuff
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two separate applications (both part of the same system) that share a
Hello I have problem to put together animations of two separate objects to second
I have two separate sets of tables in the same database that model the
I have a Cake website and it needs to have two separate logins, each
I have 2 separate Java Applications running at a time. (Two separate javaw.exe) I
I have two separate objects, a main and a child. Its physically not a
I have created two separate objects, one of class Order and one of class
Here's the situation. Let's say we have two separate object types, and we want
Working in Java: I have a JFrame class, and separate classes for my two
I'm trying to attach a single NetStream Object to two separate Video objects instead

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.