mango-gremlin / arch-enemies

This repository represents the work done by 10 students aiming to program their first game using GODOT. It allows for insights of struggles that we've had throughout development and now, at the end of the semester, contains a playable demo-game!
https://mango-gremlin.itch.io/arch-enemies
MIT License
7 stars 0 forks source link

overworld | improve location of State load and save methods #89

Open ScatteredDrifter opened 11 months ago

ScatteredDrifter commented 11 months ago

Overview

builds up on #56 As of now the code for loading and saving the player's information is contained in maingame.gd and is used in its attached node, but also on several other nodes that are changing the active scene ( i.e. pause menu or bridging game ).

Whenever a scene is changed the current state of the world is saved to a file and loaded upon entering the overworld again.

This works so far, yet the current structure is not nice for several reasons

Implementation

As of now its not sure where to set those functions because we have not merged our prototypes yes. What this means is that our base structure for the actual game was not set up yet and thus is prone to change anyway after some implementation.

However it might be useful to: Create a folder within /scripts that is devoted for saving and loading states/configurations and more. That is because we will have further components that need to load and save information, such as:

ScatteredDrifter commented 11 months ago

State:

for now this has been resolved in #93:

However it might not be the best solution possible to implement a save-system as its own class. Maybe we can simplify it by removing the class those scripts are contained in to make it easier to run and call.

Advantage of class ( current implementation ) :

Because we have to initialize the object on startup we gather the following advantage: -> We can save and update internal representations / references to models.

Example:

The player contains a method .saveState() which is gathering all its information in the current scene ( coordinates, inventory etc. ) By giving the constructor a reference to the player-node that is used and run in the overworld it can easily call this function upon running .saveconfig(). This will continue to function even after leaving the scene because the reference will hold true after entering the scene once again at a later point.