fix: make the shot bouton lock the player angle

This commit is contained in:
Kazhnuz 2021-11-27 13:20:32 +01:00
parent 5754d93cc5
commit 257f1f29c3

View file

@ -39,9 +39,10 @@ function Player:updateStart(dt)
self.zsp = 280*1.33
end
if self.keys["B"].isPressed then
if self.keys["B"].isDown then
self.weapons:shoot(self.x, self.y+1, self.z+8, self.angle)
end
self.weapons:update(dt)
end
function Player:basicMovements()
@ -83,7 +84,10 @@ function Player:basicMovementsFree()
if (xsp ~= 0 or ysp ~= 0) then
local angle = utils.math.pointDirection(0, 0, xsp, ysp)
self.angle = angle
if not self.keys["B"].isDown then
self.angle = angle
self:setDirection(xsp)
end
self.xsp, self.ysp = utils.math.lengthdir(160, angle)
end
end
@ -105,7 +109,6 @@ end
function Player:setAnimation()
local gsp = utils.math.pointDistance(0, 0, self.xsp, self.ysp)
self.sprite:setCustomSpeed(math.abs(gsp) / 12)
self:setDirection(self.xsp)
if (self.action == "punching") then
--the animation system is already active
else