Wrote main animation loop