We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Collision Detection Between Two Rectangles
Page Index Toggle Pages: 1
Collision Detection Between Two Rectangles (Read 824 times)
Collision Detection Between Two Rectangles
Jul 16th, 2007, 5:28am
 
How would I test collision against two rendered rectangles? I'm doing a pong program for a game design class in which we rely solely on Processing as our development language, and I need to test collision against the ball (which is a rectangle) and paddles. As of now, all I've managed to do is create an invisible barrier starting at the x coordinates of the paddles, but I can't figure out a way to only constrain that to the front line of the rectangle. Is there any good way of doing this?
Re: Collision Detection Between Two Rectangles
Reply #1 - Jul 16th, 2007, 8:54am
 
http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Rectangle.html
intersects(Rectangle r)
Determines whether or not this Rectangle and the specified Rectangle intersect.

Hope this helps you in some way Smiley
Re: Collision Detection Between Two Rectangles
Reply #2 - Jul 16th, 2007, 11:49am
 
snipper says:
http://snippet.seltar.org/index.php?pid=3&sid=14

F
Page Index Toggle Pages: 1