Game resolution conundrums

How does this work?

Let’s say my game is 1920 x 1080, and I spawn an object at specific coordinates, e.g. X: 1200, Y: 900.
Once I boot the game and change the resolution to let’s say 800 x 600, will the object spawn outside of the screen? Or is the game’s resolution always 1920 x 1080 and it’s just scaled down (or up), but all the fixed coordinates will always be rendered at the same relative position on the screen regardless of what resolution is set?

Screen coordinates and world coordinates are not the same. One maps to the other. Otherwise you would not be able to scroll or zoom in world view.

So, the coordinates relate to the game world, and the screen resolution only defines how much of the world is shown? Am I understanding is correctly?

Hello again. No.

Screen space coordinates map to the screen. This tells you where a pixel is relative to the corner of the screen.

World space coordinates map to the world. This tells you where any worldspace point is located, relative to the world center.

Could you show me an example of a screen space coordinates vs world space coordinates?

A space has multiple dimensions such as up/down or left/right, expressed as variables X, Y and Z.

Where all these values are zero is the center point of that space.

Where zero is defined in any space is arbitrary. For example we may refer to the upper left pixel on the screen as being center. In that case, the X (horizontal) coordinate would increase towards the right side of the screen and the Y (vertical) coordinate would increase towards the bottom.

World (game) space is also a space, but it doesn’t exist in physical reality, like a screen. Screen and game space might align, but when we flip the camera around, all objects still have the same spatial relationship as they did before. So the world space stays the same, but it looks completely different, like upside-down, because of how it is projected onto screen space. When you watch the same scene from the opposite direction, shapes which previously seemed to the observer to move left, now move to the right, but seen from the perspective of the shapes, nothing changed.

In screen space we count pixels but in a virtual game space we count virtual units, which are mathematical.

Does that help?

Yes. That’s exactly correct. The screen resolution (plus camera zoom factor) defines the size of the viewport onto the scene.

To answer your original question, if the resolution is 1920x1080, the camera hasn’t moved and an object is spawned at 1200, 900, then it will appear on the screen.

If you change the resolution to 800x600, don’t move the camera and spawn the same object, it will be off screen. The co-ordinates are not scaled.

FWIW, GDevelop doesn’t have screen co-ordinates. All co-ordinates are for the scene.

@per thank you, that is interesting, though I’m still not sure how to apply this in practice to resolution and coordinates.

@MrMen, does it mean that for whatever resolutions I would like to support in the game, I would need to set a custom camera zoom, as long as I want to show the same game area on screen across all resolutions?

Yes. The camera zoom calculation is quite simple. I think it’ll be the width of the target resolution divided by the width of the actual resolution.

1 Like