Updated the animation engine

Added support for duration and looping.