walljumps
This commit is contained in:
@@ -14,6 +14,8 @@ function Player:New(x,y)
|
||||
|
||||
o.jumpImpulse = 3.5 -- gameworld pixels
|
||||
|
||||
self.wallJumpImpulse = { x = 2.5, y = 3.5 }
|
||||
|
||||
o.coyoteAmount = 5 -- int
|
||||
o.coyoteValue = 5 -- frames
|
||||
|
||||
@@ -46,6 +48,7 @@ function Player:New(x,y)
|
||||
o.canFall = true
|
||||
o.canFriction = true
|
||||
o.maskType = animation.moth_mask
|
||||
o.wallHit = 0
|
||||
|
||||
o.anchorRespawn = {
|
||||
x = o.pos.x,
|
||||
@@ -93,6 +96,9 @@ function Player:Smart()
|
||||
if self.coyoteValue > 0 then
|
||||
self.vel.y = -self.jumpImpulse
|
||||
self.coyoteValue = 0
|
||||
elseif self.wallHit ~= 0 then
|
||||
self.vel.y = -self.wallJumpImpulse.y
|
||||
self.vel.x = -self.wallJumpImpulse.x * self.wallHit
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -233,7 +239,9 @@ function Player:DoPhysics()
|
||||
-- horizontal collision
|
||||
if not self:isCollidingAt(self.pos.x + self.vel.x + self.move_x, self.pos.y, LoadedObjects.Collisions) then
|
||||
self.pos.x = self.pos.x + self.vel.x + self.move_x
|
||||
self.wallHit = 0
|
||||
else
|
||||
self.wallHit = math.sign(self.vel.x + self.move_x)
|
||||
self.vel.x = 0
|
||||
end
|
||||
|
||||
@@ -313,3 +321,7 @@ function Player:Unhook()
|
||||
self.isHooked = false
|
||||
self.hookAnchor = nil
|
||||
end
|
||||
|
||||
function Player:Debug()
|
||||
love.graphics.print("wallHit: "..self.wallHit)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user