Compare commits

..

No commits in common. "7e86da7806cf0bb76a120323d403c2f2810cacff" and "5f0256e0afc22c4f091fb621b7ff06b7d3be79c7" have entirely different histories.

3 changed files with 162 additions and 189 deletions

View File

@ -73,16 +73,16 @@ function Player:Smart()
if math.abs(self.vel.x) < self.zeroSpeed then self.vel.x = 0 end
if Keybind:Check(Keybind.move.left) then
if keybind:Check(keybind.moveLeft) then
self.move_x = -self.moveSpeed
elseif Keybind:Check(Keybind.move.right) then
elseif keybind:Check(keybind.moveRight) then
self.move_x = self.moveSpeed
else
self.move_x = 0
end
self.vel.x = self.vel.x
if Keybind:Check(Keybind.move.jump) then
if keybind:Check(keybind.moveJump) then
if self.isOnGround then
self.vel.y = -self.jumpImpulse
end
@ -90,18 +90,18 @@ function Player:Smart()
end
self.dashCooldownTimer = math.max(0,self.dashCooldownTimer - current_dt)
if Keybind:Check(Keybind.move.dash) then
if keybind:Check(keybind.moveDash) then
if self.dashCooldownTimer == 0
and not self.isDashing
and self.dashCount > 0 then
self.dashCount = self.dashCount - 1
self.isDashing = true
local vertical = 0
if Keybind:Check(Keybind.move.down) then vertical = vertical + 1 end
if Keybind:Check(Keybind.move.up) then vertical = vertical - 1 end
if keybind:Check(keybind.moveDown) then vertical = vertical + 1 end
if keybind:Check(keybind.moveUp) then vertical = vertical - 1 end
local horizontal = 0
if Keybind:Check(Keybind.move.right) then horizontal = horizontal + 1 end
if Keybind:Check(Keybind.move.left) then horizontal = horizontal - 1 end
if keybind:Check(keybind.moveRight) then horizontal = horizontal + 1 end
if keybind:Check(keybind.moveLeft) then horizontal = horizontal - 1 end
if horizontal == 0 and vertical == 0 then
horizontal = self.sprite_flip.x

View File

@ -1,9 +1,7 @@
Keybind = {}
Keybind.move = {}
Keybind.menu = {}
keybind = {}
function Keybind:Check(action)
for _, keyname in pairs(action) do
function keybind:Check(key)
for _, keyname in pairs(key) do
if type(keyname) == "string" then
if love.keyboard.isDown(keyname) then return true end
else
@ -13,36 +11,11 @@ function Keybind:Check(action)
return false
end
function Keybind:Colision(cat, key)
for _, action in pairs(cat) do
for _, keyname in pairs(action) do
if key == keyname then return true end
end
end
return false
end
function Keybind:Add(action, key)
table.insert(action, key)
end
function Keybind:Change(action, position, key)
action[position] = key
end
function Keybind:Remove(action)
action = {}
end
function Keybind:Default()
Keybind.move.left = {"left", "a"}
Keybind.move.right = {"right", "d"}
Keybind.move.up = {"up", "w"}
Keybind.move.down = {"down", "s"}
Keybind.move.jump = {"z", "space"}
Keybind.move.attack = {"x", 1}
Keybind.move.dash = {"c", 2}
end
-- Set default values at start
Keybind:Default()
keybind.moveLeft = {"left", "a"}
keybind.moveRight = {"right", "d"}
keybind.moveUp = {"up", "w"}
keybind.moveDown = {"down", "s"}
keybind.moveJump = {"z", "space"}
keybind.moveAttack = {"x", 1}
keybind.moveDash = {"c", 2}