Find top, bottom, left and right side of the window?

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.
RealJace
Prole
Posts: 3
Joined: Mon Dec 06, 2021 3:26 pm

Find top, bottom, left and right side of the window?

Post by RealJace »

Hello, so I am using Windfield library and wanted to make collisions for top, bottom, left and right side of the window so player doesn't go out of the window, and of course I need position for this, but I don't know how to do this, so how can I?
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Find top, bottom, left and right side of the window?

Post by grump »

Left, top is 0, 0 and right, bottom is love.graphics.getWidth() - 1, love.graphics.getHeight() - 1
User avatar
Xii
Party member
Posts: 137
Joined: Thu Aug 13, 2020 9:09 pm
Contact:

Re: Find top, bottom, left and right side of the window?

Post by Xii »

Making the physics and collisions of your game world depend on the window size is a bad idea. Window size can change in ways you might not expect, even if you set them to specific values.
RealJace
Prole
Posts: 3
Joined: Mon Dec 06, 2021 3:26 pm

Re: Find top, bottom, left and right side of the window?

Post by RealJace »

Well my game is fullscreen sooo yeah.
User avatar
Xii
Party member
Posts: 137
Joined: Thu Aug 13, 2020 9:09 pm
Contact:

Re: Find top, bottom, left and right side of the window?

Post by Xii »

As I said, that won't work as you expect it to. People have different size screens. They can change resolution while your game is running. They can manually override fullscreen settings in graphics card configuration. There are many things which simply break your expectation here.

You should instead figure out how to render your game to a window of any size.
pauljessup
Party member
Posts: 356
Joined: Wed Jul 03, 2013 4:06 am

Re: Find top, bottom, left and right side of the window?

Post by pauljessup »

Wow, man. You're just itching for a fight, aren't you?
User avatar
pgimeno
Party member
Posts: 3672
Joined: Sun Oct 18, 2015 2:58 pm

Re: Find top, bottom, left and right side of the window?

Post by pgimeno »

pauljessup wrote: Tue Dec 07, 2021 9:31 pm Wow, man. You're just itching for a fight, aren't you?
Usually people have a thicker skin than you seem to have or think they have. Xii is giving valid criticisms.
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Find top, bottom, left and right side of the window?

Post by Jasoco »

It's true. Windows can be resized. It's best if you choose a specific playfield size and learn how to render to a specific fixed size and scale that to fit the window. Personally I render my gameplay to a canvas of a specific dimension. Usually for me it's like 320x180 as I like retro low pixel games and it's a 16:9 size. Or I render to 1920x1080 if I'm doing something higher resolution. Basically always 16:9 for me.

Then you'd use some math to scale and move the rendered canvas to fit center in the window. Just always render the game itself to that canvas and display that canvas. Then people can resize the window all they want and not break things. I think there's some libraries out there to help with screen displaying.
User avatar
darkfrei
Party member
Posts: 1204
Joined: Sat Feb 08, 2020 11:09 pm

Re: Find top, bottom, left and right side of the window?

Post by darkfrei »

grump wrote: Mon Dec 06, 2021 5:51 pm Left, top is 0, 0 and right, bottom is love.graphics.getWidth() - 1, love.graphics.getHeight() - 1
0.5, 0.5 and love.graphics.getWidth() - 0.5, love.graphics.getHeight() - 0.5,
But you can have 0 to width and 0 to height arrays for them.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Find top, bottom, left and right side of the window?

Post by grump »

darkfrei wrote: Tue Dec 14, 2021 8:10 am 0.5, 0.5 and love.graphics.getWidth() - 0.5, love.graphics.getHeight() - 0.5,
No. I think you're confusing different coordinate systems.
But you can have 0 to width and 0 to height arrays for them.
What do you mean, arrays for "them"? What is "them", pixels? And why would those arrays be larger than the window?
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 14 guests