Hello, I'm new to the Love2d engine and i'm trying to make my object stay inside the window. my script is only acting as if it doesn't detect the bottom edge of the window and the object goes underneath it.. here is my code:
function map_collisions()
if player.x < 0 then
player.x = 0
end
if player.y < 0 then
player.y = 0
end
if player.y + player.graphic:getHeight() > 700 then
player.y = 700 - player.graphic:getHeight()
end
if player.x + player.graphic:getWidth() > 800 then
player.x = 0
end
end
If you haven't touched the default settings, then the screen height is 600, not 700. You can use [wiki]love.graphics.getWidth[/wiki] and [wiki]love.graphics.getHeight[/wiki] to get the dimensions.