This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm attempting to smooth out the animation of my sprites using interpolation and am have a lot of problems.
I've managed to get some success using this method of applying the interpolation during my render call:
When the sprite is moving, it is almost perfectly smooth (it's like a 95% improvement on no interpolation) but when the sprite is static, the interpolation is still applied and the sprite therefore has a 'wobbling' effect. (It also play havoc with my collision detection but that's for another day!)
Now, I've come across another method, which seems more sensible. This method necessitates us saving the sprites previous position so the following calculation can be made in the render call:
Now, this doesn't wobble when the sprite is static, because the difference between the current and old positions would be 0. However, when the sprite moves, there is no improvement in the choppiness. It also seems to behave better with regards to collision (but this is probably because it's not actually interpolating correctly!)
Oh, and this is my game loop showing how I work out my interpolation value:
I would be very grateful if somone could tell me why the 2nd method doesn't seem to be doing anything.... is the calculation wrong? How do I go about interpolating between an object's previous and current positions?!