input-display/main.lua

85 lines
2.1 KiB
Lua

function love.load()
require("sdl")
local Button = require "button"
joysticks = love.joystick.getJoysticks()
fightstick = joysticks[1]
MENU = true
local col1 = {255/255, 179/255, 102/255}
local col2 = {150/255, 109/255, 209/255}
local col3 = {255/255, 0/255, 0/255}
--movement buttons
movement = {
Button(25, 40, 29, "dpleft", col1),
Button(90, 40, 29, "dpdown", col1),
Button(147, 71, 29, "dpright", col1),
Button(168, 180, 36, "dpup", col1),
}
--attack buttons
attack = {
Button(207, 43, 29, "x", col2),
Button(265, 17, 29, "y", col2),
Button(330, 22, 29, "rightshoulder", col2),
Button(395, 38, 29, "leftshoulder", col2),
Button(202, 110, 29, "a", col2),
Button(263, 86, 29, "b", col2),
Button(330, 88, 29, "triggerright", col2),
Button(394, 105, 29, "triggerleft", col2),
}
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})
elseif key == "r" then
resize()
elseif key == "q" then
love.event.quit()
end
end
function love.update(dt)
windowx, windowy, _ = love.window.getPosition()
mousex, mousey = love.mouse.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
end
end
function love.draw()
love.graphics.scale(WINDOWSCALE, WINDOWSCALE)
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
love.graphics.newFont(10)
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("window scale = s", 0, 32)
love.graphics.print("quit = q", 0, 48)
love.graphics.printf("open/close this menu with spacebar", 0, 254, 480, "center")
love.graphics.setColor(60/255, 60/255, 60/255)
love.graphics.newFont(6)
love.graphics.printf("made by levi leggott - 2025", 0, 238, 480, "center")
end
end