Jump to content

  • Log In with Google      Sign In   
  • Create Account

collision of ball and rectangle


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 abeylin   Members   -  Reputation: 242

Like
0Likes
Like

Posted 28 January 2012 - 12:14 AM

I'd like to figure out how to deal with collision similar to arcanoid game only where the paddle can have slope different than 0.

An image is attached of what I'm trying to explain, and even though the paddle seems to be at 45 degree angle, I'd like it to be at any angle.
image.jpg

Ultimately I'd like to know how to calculate the trajectory after impact, but any help is greatly appreciated - including how to even detect that there was a collision.

http://www.mildspring.com - developing android games


Sponsor:

#2 SimonForsman   Crossbones+   -  Reputation: 6306

Like
1Likes
Like

Posted 28 January 2012 - 12:48 AM

http://mathworld.wol...tersection.html

testing against the front of the paddle should be sufficient, unless the ball moves really fast in which case you could:
*split up the movement into smaller parts and make more tests.
or
*Check if the line from the balls old to new position intersects with the paddle (google line-line intersection)
or
*Check what side of the line the old and new position of the ball is and if it changes side without triggering a colission do either of the above.
http://www.gamedev.n...ine-a-point-is/

To get the basic trajectory after impact you could:

1) Get the paddles Normal (a vector pointing forward or out from the paddle)
2) Check the angle between the balls movement vector and the paddles normal
3) Reflect the ball back on the other side of the normal. (So if it goes in towards the paddle at an angle of 20 degrees to the normal you send it out at -20 degrees from the normal) (For normal breakout you tend to adjust the reflection angle based on the distance from the center of the paddle instead, but in your case that shouldn't be needed as the player can control the angle the ball hits from instead, but you could try adjusting based on distance from center aswell and see if that provides better gameplay)
I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

#3 wildbunny   Members   -  Reputation: 550

Like
0Likes
Like

Posted 28 January 2012 - 05:21 PM

I'd like to figure out how to deal with collision similar to arcanoid game only where the paddle can have slope different than 0.

An image is attached of what I'm trying to explain, and even though the paddle seems to be at 45 degree angle, I'd like it to be at any angle.
image.jpg

Ultimately I'd like to know how to calculate the trajectory after impact, but any help is greatly appreciated - including how to even detect that there was a collision.


You need a circle vs OBB routine - I describe this in my article on collision detection:

http://www.wildbunny.co.uk/blog/2011/04/20/collision-detection-for-dummies/

:)

Cheers, Paul.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS