A while ago, I started playing with Love2d a bit, eventually left it. Came back, tried using the collision code I used in my previous experience, and it doesn't work anymore.
function clamp(value, low, high)
if value < low then
value = low
elseif value > high then
value = high
end
return value
end
player.x = clamp(player.x, 0, 800 - player.images:getWidth())
player.y = clamp(player.y, 0, 600 - player.images:getHeight())
function clamp(value, low, high)
if value < low then
value = low
elseif value > high then
value = high
end
return value
end
player.x = clamp(player.x, 0, 800 - player.images:getWidth())
player.y = clamp(player.y, 0, 600 - player.images:getHeight())
function clamp(val, high, low)
return (val > high and high) or (val < low and low) or val
end
Forgot where I saw the "(conditional and value) or (conditional and value)" where it only returns the value and not the conditions boolean. Though I don't understand it, I implemented it into clamp. Infact I think I might ask a question about that in the questions that don't deserve their own thread.