Skip to content

Instantly share code, notes, and snippets.

@TheLinx
Created May 7, 2010 19:56
Show Gist options
  • Save TheLinx/393934 to your computer and use it in GitHub Desktop.
Save TheLinx/393934 to your computer and use it in GitHub Desktop.
-- function goes here somewhere
function love.load()
sprites = {}
numberOfSprites = 62
spriteLoadIterator = num_iter(1, numberOfSprites)
spriteLoadProgress = 0
spritesLoaded = false
end
function love.update(dt)
if not spritesLoaded then
local n = spriteLoadIterator()
if n then
sprites[n] = love.graphics.newImage(n..".png")
spriteLoadProgress = n
else
spritesLoaded = true
end
else
-- sprites loaded, do game stuff
end
end
function love.draw()
if not spritesLoaded then
love.graphics.print("Loading sprites: "..spriteLoadProgress.."/"..numberOfSprites, 50, 50)
else
-- draw game stuff
end
end
function num_iter(s, e)
local i = s - 1
return function()
i = i + 1
if i <= e then
return i
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment