As obj.timer was never set, there was issues applying fps and changing direction programmatically while the animation was running.