function love.load()
	require("sdl")
	local Button = require "button"
	local Slider = require "slider"
	
	joysticks = love.joystick.getJoysticks()
	fightstick = joysticks[1]
	font = love.graphics.newFont("NCZ.otf", 12)
	MENU = true
	col1 = {255/255, 179/255, 102/255}
	col2 = {150/255, 109/255, 209/255}
	
	--movement buttons
	movement = {
		Button(37.5, 60, 43.5, "dpleft", col1),
		Button(135, 60, 43.5, "dpdown", col1),
		Button(220.5, 106.5, 43.5, "dpright", col1),
		Button(252, 270, 54, "dpup", col1),
	}
	--attack buttons
	attack = {
		Button(310.5, 64.5, 43.5, "x", col2),
		Button(398.5, 25.5, 43.5, "y", col2),
		Button(495, 33, 43.5, "rightshoulder", col2),
		Button(592.5, 57, 43.5, "leftshoulder", col2),
		Button(303, 165, 43.5, "a", col2),
		Button(394.5, 127.5,  43.5, "b", col2),
		Button(495, 132, 43.5, "triggerright", col2),
		Button(592.5, 157.5, 43.5, "triggerleft", col2),
	}
	--color sliders
	slider = {
		Slider(48, 192, 256, 6, 255),
		Slider(48, 256, 256, 6, 255),
		Slider(48, 312, 256, 6, 255),
		Slider(416, 192, 256, 6, 255),
		Slider(416, 256, 256, 6, 255),
		Slider(416, 312, 256, 6, 255)
	}
end

function love.keypressed(key)
	if key == "space" then
		MENU = not MENU
	elseif key == "b" then
		BORDERLESS = not BORDERLESS
		love.window.setMode(WINDOWWIDTH, WINDOWHEIGHT, {borderless = BORDERLESS, x=windowx, y=windowy})
	elseif key == "r" then
		resize()
	elseif key == "q" then
		love.event.quit()
	elseif key == "c" then
		for i, m in ipairs(movement) do
				m.c = {slider[1].level/255, slider[2].level/255, slider[3].level/255}
		end
		for i, a in ipairs(attack) do
				a.c = {slider[4].level/255, slider[5].level/255, slider[6].level/255}
		end
	end
end

function love.update(dt)
	windowx, windowy, _ = love.window.getPosition()
	if not MENU then
		--movement buttons
		for i, v in ipairs(movement) do
			v:update(dt)
		end
		--attack button
		for i, v in ipairs(attack) do
			v:update(dt)
		end
	elseif MENU then
		for i, v in ipairs(slider) do
			v:update(dt)
		end
	end
end

function love.draw()
	love.graphics.setLineWidth(2)
	if not MENU then
		--movement buttons
		for i, v in ipairs(movement) do
			v:draw()
		end
		--attack buttons
		for i, v in ipairs(attack) do
			v:draw()
		end
	elseif MENU then
		for i, v in ipairs(slider) do
			v:draw()
		end
	--rectangles showing the results of slider color
	love.graphics.rectangle("line", 328, 191, 16, 128)
	love.graphics.rectangle("line", 376, 191, 16, 128)
	love.graphics.setColor(slider[1].level/255, slider[2].level/255, slider[3].level/255)
	love.graphics.rectangle("fill", 328, 191, 16, 128)
	love.graphics.setColor(slider[4].level/255, slider[5].level/255, slider[6].level/255)
	love.graphics.rectangle("fill", 376, 191, 16, 128)
	--text based instrunctions
	love.graphics.setFont(font, 20)
	love.graphics.setColor(150/255, 150/255, 150/255)
		love.graphics.print("hotkeys:", 0, 0)
		love.graphics.print("borderless = b", 0, 16)
		love.graphics.print("set color = c", 0, 32)
		love.graphics.print("quit = q", 0, 48)
	love.graphics.setColor(255/255, 179/255, 102/255)
		love.graphics.printf("open/close this menu with spacebar", 0, 385, 720, "center")
	love.graphics.setColor(60/255, 60/255, 60/255)
		love.graphics.printf("by mango", 0, 365, 720, "center")
	end
end

