Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

outRider

Breakout physics

This topic is 5802 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 -

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!