i'm at a complete loss right now
this is probably the fourth time i've attempted something like this, i look at examples and follow tutorials but i still can't manage to get it right. i've even in the past tried hardoncollider and that still was extremely buggy.
Code: Select all
function playerCollision()
local colliding = 'none'
for i,v in pairs(gWorld) do
local c1, c2, c3, c4 =
player.x <= v.x+50,
player.x+50 >= v.x,
player.y <= v.y+50,
player.y+50 >= v.y
if c1 and c2 and c3 and c4 then
local diffX = player.x - v.x
local diffY = player.y - v.y
colliding = '\nx: '..diffX..'\ny: '..diffY
if math.abs(diffX) > math.abs(diffY) then
if diffX < 0 then
player.x = v.x-50
else
player.x = v.x+50
end
else
if diffY < 0 then
player.y = v.y-50
player.yvel = 0
else
player.y = v.y+50
end
end
end
end
player.collisionState = colliding
end
the problem is that when you jump while moving against the box, the player jumps up on top of the box without sliding off it's edge and into the air, and I'm unable to jump when the player sits on top of the box.
love file: http://dl.dropbox.com/u/8005323/lua/lov ... thing.love