Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Interpolation using Object's old and current positions

Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All

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

Thanks all!

Hey! You're stepping on my hand! Help me tiny ad!
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic