Move sprite function to sprite.js