Results 1 to 3 of 3
Thread: Problems with square collision
- 07-31-2011, 10:49 PM #1
Member
- Join Date
- Jul 2011
- Posts
- 53
- Rep Power
- 0
Problems with square collision
So I need to program the collision of a square. The ball that will hit the object has a velocity of 4pixels/run and doesn't disperse (after collision the velocity of the ball rotates with 90 degrees).
I make two variables called xball and yball who represent the position of the middlepoint of the ball.
First I program one of the x-sides of the square to collide if the xball+radius is greater than the xposition of this side of square. I also put the two y coordinates of the square n the IF statement and also put that the xball+radius must be smaller then xposition+5 of the side of the square (since velocity of ball is 4px/run)
Now I'd like to program the y-sides of the square as well...and now comes the problem:
If I program the y-sides of the square in the way as the x-side I just did that I will have a "Bugged zone" where the ball will reflect with 180 degrees which isn't something we want...
Image to clarify:

Any idea what other method I might use that doesn't have this problem? Or another method?
Thnx in advance,
Reskaillev
- 07-31-2011, 11:26 PM #2
Are you sure? Double reflection from top and side or side and top would be 180 degsIf I program the y-sides of the square in the way as the x-side I just did that I will have a "Bugged zone" where the ball will reflect with 180 degrees which isn't something we want...
What is the square colliding with?I need to program the collision of a square
- 08-01-2011, 09:38 AM #3
Member
- Join Date
- Jul 2011
- Posts
- 53
- Rep Power
- 0
Similar Threads
-
Collision in j2me
By Ashish_jain in forum Java 2DReplies: 8Last Post: 06-24-2011, 03:58 PM -
2D - Collision messed up
By überfuzz in forum New To JavaReplies: 0Last Post: 06-22-2011, 09:20 PM -
Collision not being detected
By CNew in forum Advanced JavaReplies: 3Last Post: 12-06-2010, 07:06 AM -
Collision
By shadycharacter in forum New To JavaReplies: 0Last Post: 04-13-2010, 09:58 PM -
Two Problems Rotating and collision detection help
By jaferris in forum Java AppletsReplies: 2Last Post: 01-07-2008, 11:19 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks