iPhone Pong Advanced Deflection Angle
Posted
by CherryBun
on Stack Overflow
See other posts from Stack Overflow
or by CherryBun
Published on 2010-04-24T11:33:42Z
Indexed on
2010/04/24
12:33 UTC
Read the original article
Hit count: 335
Hi, I am currently developing a simple Pong game for the iPhone. Currently using CGRectIntersectsRect for the collision detection and as for the deflection of the ball when it hits the paddle, I just multiply the ball velocity with -1 (therefore reversing the direction of the ball).
What I am trying to do is to make it so that when the ball hits the paddle, it checks whether how far is the ball from the center of the paddle, and increases the deflection angle the further the ball is away from the center of the paddle. (E.g. In this case, the ball will be deflected back at 90 degrees no matter where it came from, as long as it hits the center of the paddle)
How am I suppose to do that?
Any help would be greatly appreciated.
Thank you.
© Stack Overflow or respective owner