Results 1 to 3 of 3
 04252012, 12:42 AM #1Member
 Join Date
 Mar 2012
 Posts
 3
 Rep Power
 0
Basic  Confusion with collision detection between squares
Heyy, I have a game where the user controls one square but I want to collect collision with another square. I know the basic layout for doing this, However, I always get my more than and less than and + and  mixed up thus i was wondering if anyone could correct them for me ?
Java Code:if (character.y > collectTwo.y && character.y + characterWidth < collectTwo.x + 10) if (character.x > collectTwo.x && character.x + characterWidth < collectTwo.x10)
Thank you so much!!
 04252012, 01:05 AM #2Moderator
 Join Date
 Feb 2009
 Location
 New Zealand
 Posts
 4,716
 Rep Power
 18
Re: Basic  Confusion with collision detection between squares
I always get my more than and less than and + and  mixed up
Two 1d line segments will interest iff the max of their left hand ends < the min of their right hand ends. (*) For rectangles this condition must hold in both dimensions simultaneously if they intersect, and for "upright" rectangles the joint condition is sufficient.
(*) But I've slipped into geometry with "left" and "right". This is reasonable in your case, I think. But what I really mean is given segments a_1>a_2 and b_1>b_2 that max(min(a_1,a_2),min(b_1,b_2)) < min(max(a_1,a_2),max(b_1,b_2))Last edited by pbrockway2; 04252012 at 01:08 AM.
 04252012, 03:22 PM #3AN21XX
 Join Date
 Mar 2012
 Location
 Munich
 Posts
 298
 Rep Power
 9
Similar Threads

Collision Detection
By Äppelpaj in forum Java 2DReplies: 1Last Post: 10132011, 03:29 PM 
Collision Detection
By sunde887 in forum Java 2DReplies: 2Last Post: 10072011, 11:40 PM 
Collision Detection?
By Alerhau in forum New To JavaReplies: 39Last Post: 09072011, 04:55 PM 
Really Need help with some collision detection
By Harwad in forum New To JavaReplies: 1Last Post: 01232011, 12:38 AM 
Magic Squares, input confusion
By bengiles89 in forum New To JavaReplies: 6Last Post: 04292010, 01:13 AM
Bookmarks