Hi!
I have a weird issue with collisions.
The jump ocurs at any time I try to move the player parallel to the colliding side (in the gif, I moved the player up).
The planet and the player have two simple collision boxes (apparently the debug collision bow drawing does not appear on the gif export :/) matching the sprite size.
The player movement is as follows
local _x, _y = self.x, self.y
local _was_x, _was_y = _x, _y
if playdate.buttonIsPressed(playdate.kButtonUp) then
_y -= 1
end
if playdate.buttonIsPressed(playdate.kButtonDown) then
_y += 1
end
if playdate.buttonIsPressed(playdate.kButtonLeft) then
_x -= 1
end
if playdate.buttonIsPressed(playdate.kButtonRight) then
_x += 1
end
local _a_x, _a_y, col, col_len = self:moveWithCollisions(_x, _y)
if col_len > 0 then
print("P", _was_x, _was_y, 'T', _x, _y, "R", _a_x, _a_y, "Diff", _a_x -_x, _a_y - _y)
end
And the planet
self.angle = (self.angle + self.speed * (2 * math.pi/playdate.getFPS())/60)
self.angle = math.fmod(self.angle, 2 * math.pi)
local x = self.cx + self.h_radius * math.cos(self.angle)
local y = self.cy + self.v_radius * math.sin(self.angle)
x = playdate.math.lerp(self.x, x, 0.5)
y = playdate.math.lerp(self.y, y, 0.5)
self:moveWithCollisions(math.floor(x), math.floor(y))
Since the expectec behavior is that the planet never stops, it's collisionResponse
is set to kCollisionTypeOverlap
, letting the player get out of the way. I have try all collisionResponses for the player with the same behaviour.
I've been looking at the problem for a while and I just cannot see it.
Any clues? Thanks in advance!