Screen detection help!

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
UC101
Prole
Posts: 1
Joined: Sun Dec 22, 2013 6:03 am

Screen detection help!

Post by UC101 »

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:

Code: Select all

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
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: Screen detection help!

Post by Roland_Yonaba »

As far as I can see, the code seems okay. Can you post a *.love file ?
Thanks.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Screen detection help!

Post by kikito »

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.
When I write def I mean function.
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests