Refactored the loading of sprite assets to a function