controller support and unfocused window added
This commit is contained in:
parent
768eed8787
commit
94ba18772b
4 changed files with 46 additions and 17 deletions
12
button.lua
12
button.lua
|
@ -10,11 +10,20 @@ function Button:new(x, y, r, b)
|
|||
end
|
||||
|
||||
function Button:update(dt)
|
||||
if love.keyboard.isDown(self.b) then
|
||||
|
||||
if self.b == "triggerleft" or self.b == "triggerright" then
|
||||
if fightstick:getGamepadAxis(self.b) == 1 then
|
||||
self.press = true
|
||||
else
|
||||
self.press = false
|
||||
end
|
||||
else
|
||||
if fightstick:isGamepadDown(self.b) then
|
||||
self.press = true
|
||||
else
|
||||
self.press = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Button:draw()
|
||||
|
@ -24,7 +33,6 @@ function Button:draw()
|
|||
else
|
||||
mode = "line"
|
||||
end
|
||||
|
||||
love.graphics.circle(mode, self.x + self.r, self.y + self.r, self.r)
|
||||
end
|
||||
|
||||
|
|
0
invis.lua
Normal file
0
invis.lua
Normal file
34
main.lua
34
main.lua
|
@ -1,23 +1,29 @@
|
|||
function love.load()
|
||||
|
||||
require("sdl")
|
||||
require("invis")
|
||||
|
||||
local Button = require "button"
|
||||
joysticks = love.joystick.getJoysticks()
|
||||
fightstick = joysticks[1]
|
||||
|
||||
--movement keys
|
||||
movement = {}
|
||||
mL = Button(8, 27, 24, "a")
|
||||
mD = Button(62, 27, 24, "s")
|
||||
mR = Button(109, 53, 24, "d")
|
||||
mU = Button(127, 144, 30, "space")
|
||||
mL = Button(8, 27, 24, "dpleft")
|
||||
mD = Button(62, 27, 24, "dpdown")
|
||||
mR = Button(109, 53, 24, "dpright")
|
||||
mU = Button(127, 144, 30, "dpup")
|
||||
|
||||
--attack keys
|
||||
attack = {}
|
||||
bA = Button(159, 29, 24, "u")
|
||||
bB = Button(208, 8, 24, "i")
|
||||
bC = Button(262, 9, 24, "o")
|
||||
bD = Button(317, 16, 24, "p")
|
||||
bE = Button(155, 85, 24, "j")
|
||||
bF = Button(206, 64, 24, "k")
|
||||
bG = Button(262, 64, 24, "l")
|
||||
bH = Button(315,72, 24, ";")
|
||||
bA = Button(159, 29, 24, "x")
|
||||
bB = Button(208, 8, 24, "y")
|
||||
bC = Button(262, 9, 24, "rightshoulder")
|
||||
bD = Button(317, 16, 24, "leftshoulder")
|
||||
bE = Button(155, 85, 24, "a")
|
||||
bF = Button(206, 64, 24, "b")
|
||||
bG = Button(262, 64, 24, "triggerright")
|
||||
bH = Button(315,72, 24, "triggerleft")
|
||||
end
|
||||
|
||||
function love.update(dt)
|
||||
|
@ -40,6 +46,10 @@ end
|
|||
|
||||
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)
|
||||
|
||||
--movement keys
|
||||
|
|
11
sdl.lua
Normal file
11
sdl.lua
Normal file
|
@ -0,0 +1,11 @@
|
|||
local ffi = require("ffi")
|
||||
ffi.cdef[[
|
||||
typedef enum
|
||||
{
|
||||
SDL_FALSE = 0,
|
||||
SDL_TRUE = 1
|
||||
} SDL_bool;
|
||||
SDL_bool SDL_SetHint(const char *name, const char *value);
|
||||
]]
|
||||
local sdl = ffi.os == "Windows" and ffi.load("SDL2") or ffi.C
|
||||
sdl.SDL_SetHint("SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS", "1")
|
Loading…
Add table
Add a link
Reference in a new issue