walljumps

This commit is contained in:
binarycat 2022-02-26 15:12:25 -05:00 committed by lustlion
parent 4efc99659c
commit e9754dc1dd
3 changed files with 15 additions and 1 deletions

View File

@ -22,6 +22,7 @@ function DebugUI()
end
end
-- player isOnGroundCheck
--love.graphics.main_Player
love.graphics.setColor(1,0,0)
end

View File

@ -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

View File

@ -158,7 +158,8 @@ function Entity:getBoundingBox(animation,top,left,bottom,right)
self.boxCollision.to.y = animation.imgs[1]:getHeight()/2 + bottom
end
-- returns true if theres a collision at that point. also marks collisioned tile as collision true
-- checks if the the reciever would collide with an object if it was positioned at the given point.
-- also marks collisioned tile as collision true
function Entity:isCollidingAt(x,y,object)
for _, collision in pairs(object) do
if collision.disable then