Yes, my mistakes for not providing enough context. I was not in a good mental state because of the confusion and boredom from the complexity of starting a new game engine.
I have some experience but they are mainly created with game libraries like KAPLAY.
These game libraries provides a very flexible way to structure your games, so I got used with this workflow of creating my own data containers and global variables just by simply declaring them like a normal variable.
Diving in Godot was a very strange and new experience to me. And the reason I asked those questions is because I want to understand those concepts so I can use them in a way Godot designed it to be.
My main problem is how to structure my game. Like where do I store the game state data (current level, money, etc)? Should I put it at the root node? I’ve been watching tutorials on YouTube about these things and I still cannot understand them. But the replies above are very helpful!
So I made a very simple game, it’s like Candy Crush, and right now this is my structure
- Game (Root node) (Node2D)
- Level (Node2D)
- Grid (Where candies are being destroyed) (Node2D that instantiates candy.tscn)
- Inputs (That allows candies to be destroyed) (Control)
- Start Menu (Control)
- Main Menu (Control)
- LevelSelection (Control)
- LevelEditor (Control)
- etc
So as you can see, everything is under the Game node. That decision came to be because of how I think communication be between Inputs and Grid.
Right now, Level listens for signals that Inputs emit and gives it to Grid. When a level was finished, Grid emits the ‘level complete’ signal, and Level listens to that and emits ‘reward the player’ that Game node listen to.
And naturally, I decided to put all of the data and enums inside the Game node since the nodes are under the Game nodes anyway and gave it class_name so it’d appear in my scripts.
I really don’t know if I’m doing this right but it works, I’m just afraid it would make my codebase hard to update, messy and scary.
I would appreciate your thoughts on what I’m doing wrong and what I can improve.