Here is something to play with. Some parts of the code are commented and uncommenting some of them might change the behavior a bit.
The most important part is the one that makes sure the animation is "lag-undependent" - items will move properly regardless of the number of frames the hardware can handle.
Bookmarks