I dont fucking know how to solve this shit i hate git #3
|
@ -73,16 +73,16 @@ function Player:Smart()
|
||||||
|
|
||||||
if math.abs(self.vel.x) < self.zeroSpeed then self.vel.x = 0 end
|
if math.abs(self.vel.x) < self.zeroSpeed then self.vel.x = 0 end
|
||||||
|
|
||||||
if keybind:Check(keybind.moveLeft) then
|
if Keybind:Check(Keybind.move.left) then
|
||||||
self.move_x = -self.moveSpeed
|
self.move_x = -self.moveSpeed
|
||||||
elseif keybind:Check(keybind.moveRight) then
|
elseif Keybind:Check(Keybind.move.right) then
|
||||||
self.move_x = self.moveSpeed
|
self.move_x = self.moveSpeed
|
||||||
else
|
else
|
||||||
self.move_x = 0
|
self.move_x = 0
|
||||||
end
|
end
|
||||||
self.vel.x = self.vel.x
|
self.vel.x = self.vel.x
|
||||||
|
|
||||||
if keybind:Check(keybind.moveJump) then
|
if Keybind:Check(Keybind.move.jump) then
|
||||||
if self.isOnGround then
|
if self.isOnGround then
|
||||||
self.vel.y = -self.jumpImpulse
|
self.vel.y = -self.jumpImpulse
|
||||||
end
|
end
|
||||||
|
@ -90,18 +90,18 @@ function Player:Smart()
|
||||||
end
|
end
|
||||||
|
|
||||||
self.dashCooldownTimer = math.max(0,self.dashCooldownTimer - current_dt)
|
self.dashCooldownTimer = math.max(0,self.dashCooldownTimer - current_dt)
|
||||||
if keybind:Check(keybind.moveDash) then
|
if Keybind:Check(Keybind.move.dash) then
|
||||||
if self.dashCooldownTimer == 0
|
if self.dashCooldownTimer == 0
|
||||||
and not self.isDashing
|
and not self.isDashing
|
||||||
and self.dashCount > 0 then
|
and self.dashCount > 0 then
|
||||||
self.dashCount = self.dashCount - 1
|
self.dashCount = self.dashCount - 1
|
||||||
self.isDashing = true
|
self.isDashing = true
|
||||||
local vertical = 0
|
local vertical = 0
|
||||||
if keybind:Check(keybind.moveDown) then vertical = vertical + 1 end
|
if Keybind:Check(Keybind.move.down) then vertical = vertical + 1 end
|
||||||
if keybind:Check(keybind.moveUp) then vertical = vertical - 1 end
|
if Keybind:Check(Keybind.move.up) then vertical = vertical - 1 end
|
||||||
local horizontal = 0
|
local horizontal = 0
|
||||||
if keybind:Check(keybind.moveRight) then horizontal = horizontal + 1 end
|
if Keybind:Check(Keybind.move.right) then horizontal = horizontal + 1 end
|
||||||
if keybind:Check(keybind.moveLeft) then horizontal = horizontal - 1 end
|
if Keybind:Check(Keybind.move.left) then horizontal = horizontal - 1 end
|
||||||
|
|
||||||
if horizontal == 0 and vertical == 0 then
|
if horizontal == 0 and vertical == 0 then
|
||||||
horizontal = self.sprite_flip.x
|
horizontal = self.sprite_flip.x
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
keybind = {}
|
Keybind = {}
|
||||||
|
Keybind.move = {}
|
||||||
|
Keybind.menu = {}
|
||||||
|
|
||||||
function keybind:Check(key)
|
function Keybind:Check(action)
|
||||||
for _, keyname in pairs(key) do
|
for _, keyname in pairs(action) do
|
||||||
if type(keyname) == "string" then
|
if type(keyname) == "string" then
|
||||||
if love.keyboard.isDown(keyname) then return true end
|
if love.keyboard.isDown(keyname) then return true end
|
||||||
else
|
else
|
||||||
|
@ -11,11 +13,36 @@ function keybind:Check(key)
|
||||||
return false
|
return false
|
||||||
end
|
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
|
||||||
|
|
||||||
keybind.moveLeft = {"left", "a"}
|
function Keybind:Add(action, key)
|
||||||
keybind.moveRight = {"right", "d"}
|
table.insert(action, key)
|
||||||
keybind.moveUp = {"up", "w"}
|
end
|
||||||
keybind.moveDown = {"down", "s"}
|
|
||||||
keybind.moveJump = {"z", "space"}
|
function Keybind:Change(action, position, key)
|
||||||
keybind.moveAttack = {"x", 1}
|
action[position] = key
|
||||||
keybind.moveDash = {"c", 2}
|
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()
|
||||||
|
|
Loading…
Reference in New Issue