Sign in to follow this  
Verile

Smooth Pong Movement

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this