moonshine = nil
effect = nil

currentScene = nil
currentPlayer = nil
LoadScene = nil
TitleScene = nil

bg = { r= 31/255, g= 44/255, b= 56/255, a= 1 }
text = { r=239/255, g= 247/255, b= 255/255, a= 1 }
accent = { r=255/255, g= 194/255, b= 62/255, a= 1 }

lily = require "vendor/lily"

function love.load()
	love.mouse.setVisible(false)

	Object = require "vendor/classic"

	require "vendor/math"
	flux = require "vendor/flux"
	sfxr = require "vendor.sfxr"

	moonshine = require "shaders"
	effect = moonshine(moonshine.effects.chromasep)
		.chain(moonshine.effects.godsray)
		.chain(moonshine.effects.vignette)
		.chain(moonshine.effects.filmgrain)

	effect.chromasep.angle=1
	effect.chromasep.radius=1
	effect.godsray.weight=0
	effect.vignette.softness = 0.4
	effect.vignette.opacity = 0.2
	effect.filmgrain.size = 2

	require "scene/load"
	require "scene/title"
	require "scene/game"

	require "captain/player"
	require "captain/robertdavis"
	require "captain/stevelayer"
	require "captain/johndanger"

	require "ship/ship"
	require "ship/blackstar5"
	require "ship/excaliburiv"
	require "ship/decorator"

	require "bullet/bullet"

	require "planet/planet"

	LoadScene = LoadScene()
	TitleScene = TitleScene()
	GameScene = GameScene()
	CaptainRobert = RobertDavis()
	CaptainSteve = SteveLayer()
	CaptainJohn = JohnDanger()

	currentScene = LoadScene;
	currentPlayer = CaptainSteve;
	currentPlanet = Planet()

	require "assets"
end

function love.update(dt)
	flux.update(dt)
	if currentScene ~= nil then
		currentScene:update(dt)
	end
end

function love.draw()
	love.graphics.clear(bg.r, bg.g, bg.b, bg.a)
	love.graphics.setBackgroundColor(bg.r, bg.g, bg.b, bg.a)
	love.graphics.setColor( text.r, text.g, text.b, text.a )

	if currentScene ~= nil then
		effect(function()
			currentScene:draw()
		end)

		currentScene:drawHud()
	end

end

function love.quit()
	love.mouse.setVisible(true)
end

function love.keypressed( key, unicode )
	if key == "f4" and (love.keyboard.isDown("ralt") or love.keyboard.isDown("lalt"))
		or key == "escape" then
		love.event.quit();
	end

	if currentScene ~= nil then
		currentScene:keypressed( key, unicode )
	end
end
