Compare commits

..

No commits in common. "9307369199a03f5662865b5b8bd33dc405ba0e8e" and "389eaed2850719e60046d54a5fcd934a0310664d" have entirely different histories.

2 changed files with 15 additions and 27 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 math.abs(self.vel.x) < self.zeroSpeed then self.vel.x = 0 end
if keybind:Check(keybind.moveLeft) then if love.keyboard.isDown(keybind.moveLeft) then
self.move_x = -self.moveSpeed self.move_x = -self.moveSpeed
elseif keybind:Check(keybind.moveRight) then elseif love.keyboard.isDown(keybind.moveRight) 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 love.keyboard.isDown(keybind.moveJump) 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 love.keyboard.isDown(keybind.moveDash) 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 love.keyboard.isDown(keybind.moveDown) then vertical = vertical + 1 end
if keybind:Check(keybind.moveUp) then vertical = vertical - 1 end if love.keyboard.isDown(keybind.moveUp) then vertical = vertical - 1 end
local horizontal = 0 local horizontal = 0
if keybind:Check(keybind.moveRight) then horizontal = horizontal + 1 end if love.keyboard.isDown(keybind.moveRight) then horizontal = horizontal + 1 end
if keybind:Check(keybind.moveLeft) then horizontal = horizontal - 1 end if love.keyboard.isDown(keybind.moveLeft) 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

View File

@ -1,21 +1,9 @@
keybind = {} keybind = {}
function keybind:Check(key) keybind.moveLeft = "left"
for _, keyname in pairs(key) do keybind.moveRight = "right"
if type(keyname) == "string" then keybind.moveUp = "up"
if love.keyboard.isDown(keyname) then return true end keybind.moveDown = "down"
else keybind.moveJump = "z"
if love.mouse.isDown(keyname) then return true end keybind.moveAttack = "x"
end keybind.moveDash = "c"
end
return false
end
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}