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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:16:20+00:00 2026-06-13T19:16:20+00:00

So basically im trying to figure out how to make a proper collision between

  • 0

So basically im trying to figure out how to make a proper collision between two Rectangles.
Detecting isn’t the problem, but the rectangles begin to clip. I wanted to reset the position, but how do I do that.
I’m trying to use dx and dy to reset, but it won’t reset to the right coordinates.

https://i.stack.imgur.com/IU6sK.png (Sorry I can’t use images yet)

System.out.println(this.y + this.h + " " +  e.getY());
if(this.y + this.h >= e.getY())
{
    if(this.dy > 0)
    {
        this.y -= delta * this.dy + 0.1; 
        this.dy = 0;
    }
    else 
    {
        this.y += delta * this.dy;
        this.dy = 0;
        this.inAir = false;
    }
}

This code is just an example to show how I am trying it for the top. (this = the white Rectangle and e = the orange one) I used my class Entity, which extends Rectangle.

I’m checking intersection before I call this. This is a function in the “white” Entity and the intersection is checked in the update function of the main loop.

If I use this, there is like 1px between the rectangles.
Any ideas?
Thanks for any help 🙂

  • 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-13T19:16:22+00:00Added an answer on June 13, 2026 at 7:16 pm

    http://docs.oracle.com/javase/6/docs/api/java/awt/Rectangle.html

    Use the Rectangle class.

    Here, some code

    http://pastebin.com/raw.php?i=TzkST3Hm

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

Sidebar

Related Questions

Basically I'm trying to figure out a way to make http://www.mysite.com/check/google.com show the contents
I'm trying to figure out how to make this code work. Basically i have
I'm trying to figure out a way to make a Java application invisible to
Basically what I'm trying to figure out is, Say I have table 1 tbl1
I am trying to figure out what is the proper way to remove an
I'm trying to figure out how to make an application popup front and above
I am trying to figure out how to make this work in EF. I
I'm trying to figure out how enums work, I'm trying to make a function
Just to make things clear. I'm trying to figure out how to build a
After two days of bashing my head and trying to figure this stuff out

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.