add sprite flipping, camera offset, clean up code