put buttons into tables, cleaned code.
This commit is contained in:
parent
94ba18772b
commit
25c8eb5304
2 changed files with 36 additions and 50 deletions
BIN
icon.png
BIN
icon.png
Binary file not shown.
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 9.9 KiB |
82
main.lua
82
main.lua
|
@ -1,70 +1,56 @@
|
||||||
function love.load()
|
function love.load()
|
||||||
|
|
||||||
require("sdl")
|
|
||||||
require("invis")
|
|
||||||
|
|
||||||
local Button = require "button"
|
|
||||||
joysticks = love.joystick.getJoysticks()
|
joysticks = love.joystick.getJoysticks()
|
||||||
fightstick = joysticks[1]
|
fightstick = joysticks[1]
|
||||||
|
|
||||||
|
require("sdl")
|
||||||
|
require("invis")
|
||||||
|
local Button = require "button"
|
||||||
|
|
||||||
|
love.window.setPosition(1440, 960-373)
|
||||||
|
|
||||||
--movement keys
|
--movement keys
|
||||||
movement = {}
|
movement = {
|
||||||
mL = Button(8, 27, 24, "dpleft")
|
Button(8, 27, 24, "dpleft"),
|
||||||
mD = Button(62, 27, 24, "dpdown")
|
Button(62, 27, 24, "dpdown"),
|
||||||
mR = Button(109, 53, 24, "dpright")
|
Button(109, 53, 24, "dpright"),
|
||||||
mU = Button(127, 144, 30, "dpup")
|
Button(127, 144, 30, "dpup"),
|
||||||
|
}
|
||||||
|
|
||||||
--attack keys
|
--attack keys
|
||||||
attack = {}
|
attack = {
|
||||||
bA = Button(159, 29, 24, "x")
|
Button(159, 29, 24, "x"),
|
||||||
bB = Button(208, 8, 24, "y")
|
Button(208, 8, 24, "y"),
|
||||||
bC = Button(262, 9, 24, "rightshoulder")
|
Button(262, 9, 24, "rightshoulder"),
|
||||||
bD = Button(317, 16, 24, "leftshoulder")
|
Button(317, 16, 24, "leftshoulder"),
|
||||||
bE = Button(155, 85, 24, "a")
|
Button(155, 85, 24, "a"),
|
||||||
bF = Button(206, 64, 24, "b")
|
Button(206, 64, 24, "b"),
|
||||||
bG = Button(262, 64, 24, "triggerright")
|
Button(262, 64, 24, "triggerright"),
|
||||||
bH = Button(315,72, 24, "triggerleft")
|
Button(315,72, 24, "triggerleft"),
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
--movement keys
|
--movement keys
|
||||||
mL:update(dt)
|
for i, v in ipairs(movement) do
|
||||||
mD:update(dt)
|
v:update(dt)
|
||||||
mR:update(dt)
|
end
|
||||||
mU:update(dt)
|
|
||||||
|
|
||||||
--attack keys
|
--attack keys
|
||||||
bA:update(dt)
|
for i, v in ipairs(attack) do
|
||||||
bB:update(dt)
|
v:update(dt)
|
||||||
bC:update(dt)
|
end
|
||||||
bD:update(dt)
|
|
||||||
bE:update(dt)
|
|
||||||
bF:update(dt)
|
|
||||||
bG:update(dt)
|
|
||||||
bH:update(dt)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.draw()
|
function love.draw()
|
||||||
|
|
||||||
for i, joystick in ipairs(joysticks) do
|
|
||||||
love.graphics.print(joystick:getName(), 10, i * 20)
|
|
||||||
end
|
|
||||||
|
|
||||||
love.graphics.setBackgroundColor(1, 179/255, 102/255)
|
love.graphics.setBackgroundColor(1, 179/255, 102/255)
|
||||||
|
|
||||||
--movement keys
|
--movement keys
|
||||||
mL:draw()
|
for i, v in ipairs(movement) do
|
||||||
mD:draw()
|
v:draw()
|
||||||
mR:draw()
|
end
|
||||||
mU:draw()
|
|
||||||
|
|
||||||
--attack keys
|
--attack keys
|
||||||
bA:draw()
|
for i, v in ipairs(attack) do
|
||||||
bB:draw()
|
v:draw()
|
||||||
bC:draw()
|
end
|
||||||
bD:draw()
|
|
||||||
bE:draw()
|
|
||||||
bF:draw()
|
|
||||||
bG:draw()
|
|
||||||
bH:draw()
|
|
||||||
end
|
end
|
Loading…
Add table
Add a link
Reference in a new issue