Jump to content
  • Advertisement
Sign in to follow this  
Verile

Smooth Pong Movement

This topic is 4896 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 have seen a couple posts regarding the smooth movement of the ball in Pong. Some people have noted that the movement is more smooth if you use float values for the speed. My question is how does using a float help at all. When I have tried to use float values they just get rounded to ints whenever I write to the buffer or screen. Thanks

Share this post


Link to post
Share on other sites
Advertisement
Floats do get rounded to ints when writing to the screen, but they still remain as floats during your calculations. You don't accumulate as much round-off error by using floats in your calculations.

Edit: Oops, I did not read about the speed. I would apply the same reasoning for using floats for the speed. Movement can be made to appear much smoother when using floats because you don't have to make big leaps in values like you would by going from one int to the next (relatively speaking). I would further support the use of floats if you are increasing or decreasing speed at all in your game.

Share this post


Link to post
Share on other sites
They key is that the number in memory does not get cropped, just what is displayed for that frame. So if you consistently move a ball with velocity of 4.2 and 3.5 and use integers to store the position you will e actually updating it by 4 and 3. That is the difference, this inaccuracy adds up while cropping to an int when rendering does not create inaccuracy that adds up, next frame the estimation is still derived by accurate data.

Hope that helps.

**edit** Was beaten to posting, what I'm saying is exactly the same as above poster.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!