Source

blank LOVE / main.lua

--[[----------------------------------------------------------------------------
Copyright (c) 2011, Danny Fritz <dannyfritz@gmail.com>
http://creativecommons.org/licenses/by/3.0/
Licensed under the Creative Commons Attribution 3.0 Unported License.
--]]----------------------------------------------------------------------------

require 'lib.middleclass'
Stateful = require 'lib.middleclass.stateful.stateful'

require 'lua.Gamestate'
require 'splash.LoveSplash'
require 'splash.Splash'
require 'lua.Menu'

function love.run()
  if love.load then love.load(arg) end
  local dt = 0
  while true do
    if love.timer then
      love.timer.step()
      dt = love.timer.getDelta()
      if dt>1/60 then
      	dt = 1/60
      end
    end
    if love.update then love.update(dt) end
    if love.graphics then
      love.graphics.clear()
      if love.draw then love.draw() end
    end
    if love.event then
      for e,a,b,c in love.event.poll() do
        if e == "q" then
          if not love.quit or not love.quit() then
            if love.audio then
               love.audio.stop()
            end
            return
          end
        end
        love.handlers[e](a,b,c)
      end
    end
    if love.timer then love.timer.sleep(0.001) end
    if love.graphics then love.graphics.present() end
  end
end


--------------------------------------------------------------------------------
function love.load()
	gamestate = Gamestate:new()
	gamestate:gotoState('LoveSplash')
end

--------------------------------------------------------------------------------
function love.update(dt)
	gamestate:update(dt)
end

--------------------------------------------------------------------------------
function love.draw()
	gamestate:draw()
end

--------------------------------------------------------------------------------
function love.focus(f)
	gamestate:focus(f)
end

--------------------------------------------------------------------------------
function love.joystickpressed(joystick, button)
	gamestate:joystickpressed(joystick, button)
end

--------------------------------------------------------------------------------
function love.joystickreleased(joystick, button)
	gamestate:joystickreleased(joystick, button)
end

--------------------------------------------------------------------------------
function love.keypressed(key, unicode)
	gamestate:keypressed(key, unicode)
end

--------------------------------------------------------------------------------
function love.keyreleased(key)
	gamestate:keyreleased(key)
end

--------------------------------------------------------------------------------
function love.mousepressed(x, y, button)
	gamestate:mousepressed(x, y, button)
end

--------------------------------------------------------------------------------
function love.mousereleased(x, y, button)
	gamestate:mousereleased(x, y, button)
end

--------------------------------------------------------------------------------
function love.quit()
	gamestate:quit()
end