You can also see the problem I'm having in the prototype below. It seems that whenever the player hits the ground, there's a little bit of a stutter where it doesn't recognize them as having landed right away, but rather flips back between them several times before settling on the ground. I suspect this has to do with the collision, and the way the game detects whether you're on land:
Code: Select all
function Player:collideY(dt)
local halfX = self.width / 2
local halfY = self.height / 2
local nextY = math.floor(self.y + (self.yspeed * dt))
local nextX = math.floor(self.x + (self.xspeed * dt))
self.onGround = false
if self.yspeed < 0 then -- check upward
if(self:isColliding(map, self.x - halfX, nextY - halfY))
or(self:isColliding(map, self.x + halfX - 1, nextY - halfY)) then
return true
end
else if self.yspeed > 0 then -- check downward
if(self:isColliding(map, self.x - halfX, nextY + halfY))
or(self:isColliding(map, self.x + halfX - 1, nextY + halfY)) then
self.onGround = true
return true
end
end
return false
end