Platformer game troubles
Posted: Sun Jun 16, 2013 1:49 am
So, I've been working on a game of my own in the Löve engine, and the platforming is getting along pretty well. You can see it in the prototype below. Thanks to MasterShizzle's platforming tutorial, YellowAfterlife's platformer game engine, and the amazing Mr Rescue for their help in my figuring out how to create an engine I'm satisfied with.
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:
Any ideas?
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