Made HasPressed function and implemented it

This commit is contained in:
bizcochito
2022-01-19 14:55:15 +01:00
parent 0305dd4fc2
commit 03793e1fb8
3 changed files with 47 additions and 35 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:CheckDown(Keybind.move.left) then
self.move_x = -self.moveSpeed
elseif Keybind:Check(Keybind.move.right) then
elseif Keybind:CheckDown(Keybind.move.right) 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:CheckDown(Keybind.move.jump) 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:CheckDown(Keybind.move.dash) 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:CheckDown(Keybind.move.down) then vertical = vertical + 1 end
if Keybind:CheckDown(Keybind.move.up) 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:CheckDown(Keybind.move.right) then horizontal = horizontal + 1 end
if Keybind:CheckDown(Keybind.move.left) then horizontal = horizontal - 1 end
if horizontal == 0 and vertical == 0 then
horizontal = self.sprite_flip.x