fork download
  1. local animations = {}
  2. local activeFrame
  3. local currentFrame = 1
  4.  
  5. function love.load()
  6. animations[1] = love.graphics.newImage("512px-Kirby.png")
  7. animations[2] = love.graphics.newImage("kirby.png")
  8. activeFrame = animations[currentFrame]
  9. end
  10.  
  11. function love.update(dt)
  12.  
  13. end
  14.  
  15. function love.draw()
  16. love.graphics.draw(animations[1], love.graphics.getWidth () / 2, love.graphics.getHeight () / 2, 0, 0.2, 0.2, 256, 239.5)
  17. love.graphics.draw(animations[2], love.graphics.getWidth () / 2, love.graphics.getHeight () / 2, 0, 0.2, 0.2, 531.5, 414.5)
  18. --Loads the png into the image variable.
  19.  
  20. end
  21.  
  22. --In Lua all values are true except false and nil, therefore every variable needs to be defined previously in order to not return an error.
  23. local elapsedTime = 0
  24.  
  25. function love.update(dt)
  26. elapsedTime = elapsedTime + dt
  27.  
  28. if(elapsedTime > 1) then
  29. if(currentFrame < 2) then
  30. currentFrame = currentFrame + 1
  31. else
  32. currentFrame = 1
  33. end
  34. activeFrame = animations[currentFrame]
  35. elapsedTime = 0
  36. end
  37. end
Runtime error #stdin #stdout #stderr 0s 4464KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
lua5.3: prog.lua:5: attempt to index a nil value (global 'love')
stack traceback:
	prog.lua:5: in main chunk
	[C]: in ?