build sprite and update the image building function