simplified algorithm for drawing sprite: minor refactoring