cleaned code, fixed icon, buttons, and resolution

This commit is contained in:
Mango 2025-09-01 21:23:11 -07:00
commit 6ba4f47466
4 changed files with 57 additions and 76 deletions

View file

@ -13,12 +13,12 @@ end
function Button:update(dt)
if self.b == "triggerleft" or self.b == "triggerright" then
if fightstick:getGamepadAxis(self.b) == 1 then
self.press = true
self.press = true
else
self.press = false
end
else
if fightstick:isGamepadDown(self.b) then
if fightstick:isGamepadDown(self.b) then
self.press = true
else
self.press = false

View file

@ -1,14 +1,13 @@
WINDOWSCALE = 1
WINDOWWIDTH = 373*WINDOWSCALE
WINDOWHEIGHT = 212*WINDOWSCALE
WINDOWWIDTH = 480*WINDOWSCALE
WINDOWHEIGHT = 270*WINDOWSCALE
BORDERLESS = true
BLACK = true
function love.conf(t)
t.window.width = WINDOWWIDTH
t.window.height = WINDOWHEIGHT
t.window.borderless = BORDERLESS
t.window.title = "input display"
t.window.icon = "icon.png"
t.modules.physics = false
end

BIN
icon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 140 KiB

Before After
Before After

120
main.lua
View file

@ -1,80 +1,62 @@
function love.load()
joysticks = love.joystick.getJoysticks()
fightstick = joysticks[1]
require("sdl")
local Button = require "button"
love.window.setPosition(1440, 960-373)
--movement keys
movement = {
Button(8, 27, 24, "dpleft"),
Button(62, 27, 24, "dpdown"),
Button(109, 53, 24, "dpright"),
Button(127, 144, 30, "dpup"),
}
--attack keys, add {x,x,x} value to change color of button
attack = {
Button(159, 29, 24, "x"),
Button(208, 8, 24, "y"),
Button(262, 9, 24, "rightshoulder"),
Button(317, 16, 24, "leftshoulder"),
Button(155, 85, 24, "a"),
Button(206, 64, 24, "b"),
Button(262, 64, 24, "triggerright"),
Button(315,72, 24, "triggerleft"),
}
require("sdl")
joysticks = love.joystick.getJoysticks()
fightstick = joysticks[1]
local Button = require "button"
--movement keys
movement = {
Button(25, 40, 29, "dpleft"),
Button(90, 40, 29, "dpdown"),
Button(147, 71, 29, "dpright"),
Button(168, 180, 36, "dpup"),
}
--attack keys, add {x,x,x} value to change color of button
attack = {
Button(207, 43, 29, "x"),
Button(265, 17, 29, "y"),
Button(330, 22, 29, "rightshoulder"),
Button(395, 38, 29, "leftshoulder"),
Button(202, 110, 29, "a"),
Button(263, 86, 29, "b"),
Button(330, 88, 29, "triggerright"),
Button(394, 105, 29, "triggerleft"),
}
end
--switches the borderless window setting, remembering the position
function love.keypressed(key)
if key == "space" then
if BORDERLESS then
BORDERLESS = false
love.window.setMode(WINDOWWIDTH, WINDOWHEIGHT, {borderless=false, x=windowx, y=windowy})
else
BORDERLESS = true
love.window.setMode(WINDOWWIDTH, WINDOWHEIGHT, {borderless=true, x=windowx, y=windowy})
end
end
if key == "c" then
if BLACK then
BLACK = false
love.graphics.setBackgroundColor(0,1,0)
else
BLACK = true
love.graphics.setBackgroundColor(0,0,0)
end
end
--pressing b will change the borderless setting, and the position of the window is prevented from resetting during this
if key == "b" then
if BORDERLESS then
BORDERLESS = false
love.window.setMode(WINDOWWIDTH, WINDOWHEIGHT, {borderless=false, x=windowx, y=windowy})
else
BORDERLESS = true
love.window.setMode(WINDOWWIDTH, WINDOWHEIGHT, {borderless=true, x=windowx, y=windowy})
end
end
end
function love.update(dt)
windowx, windowy, _ = love.window.getPosition()
--movement keys
for i, v in ipairs(movement) do
v:update(dt)
end
--attack keys
for i, v in ipairs(attack) do
v:update(dt)
end
windowx, windowy, _ = love.window.getPosition()
--movement keys
for i, v in ipairs(movement) do
v:update(dt)
end
--attack keys
for i, v in ipairs(attack) do
v:update(dt)
end
end
function love.draw()
love.graphics.scale(WINDOWSCALE, WINDOWSCALE)
--movement keys
for i, v in ipairs(movement) do
v:draw()
end
--attack keys
for i, v in ipairs(attack) do
v:draw()
end
love.graphics.scale(WINDOWSCALE, WINDOWSCALE)
love.graphics.setLineWidth(2)
--movement keys
for i, v in ipairs(movement) do
v:draw()
end
--attack keys
for i, v in ipairs(attack) do
v:draw()
end
end