- Edited
I've been looking at save game tutorials (example) lately, and it seems that a popular way to save the game is to create dictionaries that contains all the information that needs to be saved, and when the save is loaded, the dictionary is first loaded from the file and then the corresponding in game objects are adapted/created based on the dictionaries.
However, I feel like these tutorials are somewhat detached from how real games work. A very simple example is the position of an object. For example, if your 2D game has a number of NPCs that can wander around a map, when you load that map you need to load the positions of the NPCs as well, and using the methods these tutorials taught, what you need is to save the position of each NPC as entries in the dictionary e.g.: x = 100, y = 200
. And when you load the game you need to find these entries from the dictionary and do something like: NPC.global_position = Vector2(dictionary.x, dictionary.y)
Somehow that just feels wrong. Like, surely there is a way to easily save the built-in data of some node2Ds, maybe the entire Node2D
instance can be saved instead of having its individual components saved? Maybe there is even some brute force method to save the entire game state instead of having to create huge/nested dictionaries.
So I'm asking for less general advice and more personal experience on how you handle your own game's save system. Especially for games with more physics-like environments rather than abstract state machines like a visual novel.