#New Game Architecture Problem

2 messages · Page 1 of 1 (latest)

drifting blaze
#

I have a serious problem with creating architecture for my games in Godot. I haven't found a single sensible solution anywhere that would allow me to quickly implement my ideas. The problem is how to properly embed the UI (inventory, skilltrees etc.) in the game. These are 2D grid-based games (I mainly want to make classic roguelikes). I've managed to make a few simple tech demos, but I don't know how to link it to the UI so that it's suitable for different resolutions and the game is ready for production. I'm slowly getting lost in this and it's preventing me from making a sensible game.

How do I sensibly embed a game that has a TilemapLayer so that the UI is embedded properly and everything is responsive to different screen resolutions? I haven't found any advanced courses on how to put it all together from A to Z, everything is based only on “simple examples” and not complex UIs with inventory, skill trees, and complex statistics in combination with a grid-based game.

I would be grateful for any materials on Godot 4 in this regard.

supple flare
#

Generally, you do not need your UI to be "responsive" for games. That's a webpage/application concern, whereas games typically scale all at once. Playing a game designed for 4:3 screen ratio on a widescreen doesn't usually show more of the game, it just creates black borders.
Similary, a game that's designed for HD doesn't use different sprites on a 4K screen, it just scales up entirely.
Typically, if a game is responsive, it's not automatic, and relies on the player picking a UI scaling size; this is because adapting automatically isn't typically what a player wants. For example, a player using their 4K TV might have a giant screen, but if you use that automatically, the font size and UI size will be very small for them, since they typically sit far away from the TV.
Therefore, for almost all games with almost no exceptions, you do not want the UI to be responsive to different screen resolutions, you just want the player to be able to modify the font size (and some other graphical elements) through a menu.

With this out of the way: The easiest way to ensure your UI uses the screen size if to have an intersitial CanvasLayer node. Your scene structure would be:

Root
├── Player
├── Tilemap
├── ...
└── CanvasLayer
    └── Control

Where Control is your UI.
If you need the UI to appear at a specific location (for example, where the player has clicked), then you do not need the CanvasLayer: simply move your UI at the location. To ensure it's always on screen, check if the spawning point + the UI's width divided by 2 is larger than the screen size. If yes, move it in by as much as necessary.

Does this help?