chore: make all action exemple more similar
This commit is contained in:
parent
3e5e49a8f6
commit
220668d8d6
2 changed files with 17 additions and 11 deletions
|
@ -21,26 +21,31 @@ function Player:onInit()
|
|||
end
|
||||
|
||||
function Player:update(dt)
|
||||
if love.keyboard.isDown("up") then
|
||||
if love.keyboard.isDown("up") and (not self.isPunching) then
|
||||
self.speed.y = -120
|
||||
end
|
||||
if love.keyboard.isDown("down") then
|
||||
if love.keyboard.isDown("down") and (not self.isPunching) then
|
||||
self.speed.y = 120
|
||||
end
|
||||
if love.keyboard.isDown("left") then
|
||||
if love.keyboard.isDown("left") and (not self.isPunching) then
|
||||
self.speed.x = -120
|
||||
end
|
||||
if love.keyboard.isDown("right") then
|
||||
if love.keyboard.isDown("right") and (not self.isPunching) then
|
||||
self.speed.x = 120
|
||||
end
|
||||
|
||||
if love.keyboard.isDown("a") and (self.onGround) then
|
||||
self.speed.z = 280
|
||||
assets:playSFX("gameplay.jump")
|
||||
end
|
||||
|
||||
if love.keyboard.isDown("z") then
|
||||
self.isPunching = true
|
||||
else
|
||||
self.isPunching = false
|
||||
end
|
||||
|
||||
self:setAnimation()
|
||||
|
||||
print(self.position.z, self.onGround, self.gravity.z)
|
||||
end
|
||||
|
||||
function Player:setAnimation()
|
||||
|
|
|
@ -27,10 +27,6 @@ function Player:onInit()
|
|||
end
|
||||
|
||||
function Player:update(dt)
|
||||
if love.keyboard.isDown("up") and (self.onGround) then
|
||||
self.speed.y = -280
|
||||
assets:playSFX("gameplay.jump")
|
||||
end
|
||||
if love.keyboard.isDown("down") then
|
||||
self.mainHitbox:modify({x = 0, y = 8}, {w = 16, h = 16})
|
||||
else
|
||||
|
@ -43,7 +39,12 @@ function Player:update(dt)
|
|||
self.speed.x = 120
|
||||
end
|
||||
|
||||
if love.keyboard.isDown("a") then
|
||||
if love.keyboard.isDown("a") and (self.onGround) then
|
||||
self.speed.y = -280
|
||||
assets:playSFX("gameplay.jump")
|
||||
end
|
||||
|
||||
if love.keyboard.isDown("z") then
|
||||
self.isPunching = true
|
||||
else
|
||||
self.isPunching = false
|
||||
|
|
Loading…
Add table
Reference in a new issue