Find top, bottom, left and right side of the window?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Find top, bottom, left and right side of the window?
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?
Re: Find top, bottom, left and right side of the window?
Left, top is 0, 0 and right, bottom is love.graphics.getWidth() - 1, love.graphics.getHeight() - 1
Re: Find top, bottom, left and right side of the window?
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.
Re: Find top, bottom, left and right side of the window?
Well my game is fullscreen sooo yeah.
Re: Find top, bottom, left and right side of the window?
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.
You should instead figure out how to render your game to a window of any size.
-
- Party member
- Posts: 356
- Joined: Wed Jul 03, 2013 4:06 am
Re: Find top, bottom, left and right side of the window?
Wow, man. You're just itching for a fight, aren't you?
Re: Find top, bottom, left and right side of the window?
Usually people have a thicker skin than you seem to have or think they have. Xii is giving valid criticisms.
- 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?
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.
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.
Re: Find top, bottom, left and right side of the window?
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.
Re: Find top, bottom, left and right side of the window?
No. I think you're confusing different coordinate systems.
What do you mean, arrays for "them"? What is "them", pixels? And why would those arrays be larger than the window?But you can have 0 to width and 0 to height arrays for them.
Who is online
Users browsing this forum: Google [Bot] and 14 guests