Advertisement

Breakout physics

Started by December 04, 2002 11:13 AM
0 comments, last by outRider 22 years, 2 months ago
I''m doing a little Breakout clone and am having trouble understanding how the ball behaves when it hits the paddle, and how a player can change the direction of the ball. For the vertical walls, I just mirror the direction of the ball on the line (1,0), and for the horizontal upper wall on (0,1). When it comes to the paddle I''ve tried to mirror on (0,1) as well, but that just doesn''t look right. I''ve tried observing the ball/paddle while playing a game and I see that if the ball hits the paddle in the center area then it seems to be reflected back through (0,1), but the angles change the farther you go from center. That, and if the paddle is moving I''m guessing it introduces spin, and therefore changes the direction and perhaps the velocity of the ball. Has anyone ever done this before or given it some thought? ------------ - outRider -
Vertical and horizontal walls make things simple. You can only hit the left wall with a negative x component to the velocity. After the bounce the x component will be the same magnitude, opposite sign. If you hit between frames then at the end of the frame you can be left of the left wall and your correct position is the same distance right of the left wall. So you have all that worked out.

The paddle should work exactly the same if the paddle isn''t moving. If the paddle is moving then it''s velocity adds in some proportion to the velocity of the ball. If it is moving the same direction then the ball bounces at less of an angle with the horizontal. If the opposite direction then more of an angle. Those reflect adding to the x component with either the same or opposite signs. Perhaps not physically accurate, but I think it will do what you want.
Keys to success: Ability, ambition and opportunity.

This topic is closed to new replies.

Advertisement