Restructure


Hello,

Today I've uploaded v3 of Tidying Game.

I've fixed a few bugs, the main one is that clicks were registered twice when clicking the static objects like the Monitors or PC.

The big thing I've been working on for a while is restructuring the code so that Objects (or Nodes as they are called in Godot) do not rely on Node names. The reason for this is  I need to be able to save the state of each level, so that the player can freely go back and forth through the levels in a game, like classic adventure games. If the player travelled to the Kitchen (which will be in the future update) and travelled back to the Desk, all the objects would be back in their original position, pulling the player out of the game and also its annoying.

If you want more information, the save and load method I have been using is in the Godot documentation here - https://docs.godotengine.org/en/stable/tutorials/io/saving_games.html - and I'll keep talking below.


The way my game was built before was instancing all nodes into a Desk node. Which I felt made sense organisation wise, like a folder system on a PC. It was all great until I needed to save the state of a level. 

I want the game levels accessible to the player so they can chose when and where to go to them by clicking on arrows, and I want the game to remember what the player has done each step of the way. If the player moved the keyboard into the bin on the Desk Level, I want it to stay there when they come back from the Kitchen Level. The way I've done this is through saving and loading and State Machines (which is basically a persistent script that can be references by any node anywhere in the game).

Each object updates a state machine to let it know if they have reached their completion criteria, setting a variable for each object to true or false with each movement. The code for the chalkboard updating itself is linked to these state machines. Where as before the Chalkboard was holding most of the completion criteria, so my game broke when it loaded as any Node that was saved, loads without their original name. So node Chalkboard is renamed to Node@2@23 or something like that.

The state machine is a script that is always running in the game so it can be updated for Desk Level and stay updated when the player leaves Desk Level. There is some other things I use it for, like making sure the Keyboard keeps the right sprite when it is in the bin. Before when I put the Keyboard in the bin, it would turn on its side as I wanted, then when leaving and coming back to the Desk Level the Keyboard would be sat in its original horizontal position. Now the Keyboard runs code on ready, to check if it is in the bin, and if so makes sure its sprite is the right one for the bin.

I restructured all the objects that you can click and pick up so that they can be instanced into the game at any point and no rely on other objects. Each object has code so that you can pick them up and put them down and for the object to know where it is in the level, where it is on the desk.

For example the Mouse has code to show when it is on the Mousepad (its completion criteria), the cat mats, the plate, the main desk and the bin. The Mouse code was referencing its own location in comparison to the location of the objects listed above, then seeing if that matched the criteria I defined. From there it would play the right sound and update the Chalkboard if it was in the right location or not.

I have now restructured all objects so that they have several Area2d nodes in their main node so I can use them to match the location of the Mousepad, Cat Mats, Plate, Desk and Bin. The Objects now would work how I wanted work even if the level was completely blank so they can be instanced into any level and used as a template for all future movable objects.

The next things to come are new levels. A Kitchen Level where no doubt the player will be tidying up my messes and a Living Room Level where surprisingly more tidying will be expected of the player. Then I am going down two paths, trying to make that a complete but small game or maybe opening it up to more and more scenes that take the player on a story.

Files

Tidying Game Windows v3 33 MB
Nov 26, 2023
Web v3.zip Play in browser
Nov 26, 2023

Get Tidying Game

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.