PictureThis – Devlog 02 – Scenes

Project structure. It’s something I’ve learned to love over the past few years, especially how to make it as efficient as possible. In this project specifically I needed to make sure I can quickly create a new level without having to write any more code. Therefor the project structure needs to be clean, easy to maintain and requires little setup time.

Godot Scenes workflow

To understand the project setup you need to understand Godot slightly. The Godot engine works with Scene files. These are just objects in the large sense of the word. Anything can be a Scene, a character can be a Scene, a trashcan can be a scene, even an entire gameworld can be a scene. You see it can become quite a spaghetti if not thought through enough. To make it more understandable for myself I thought of a scene in this way. Can I make a Scene contain anything it needs to “live” on its own and is this scene than ready to re-use without needing any extra code? Does it have no external dependencies? Does it contain only contain which it allways requires to have? If for all those questions the answere is yes, then I can safely save that object as a scene.

Images, dropzones and country

In this project I have 3 major scenes defined which together form the base of the game. Those are:

  • Images
  • Places to put those images
  • A level

Let’s have a look at two of these, images and the level. Let’s start with the first one, the images

This here is the ImageObjectTemplate. It’s a scene which contains quite some functionality. First of all it has a Sprite node (scenes consists of nodes which contain functionality in itself) which is the container of an image. Then we have another Sprite node which contains the picture frame. The picture frame in itself have a few child nodes to detect interaction from the player, another Sprite node to control highlights and a label to display text. The last node is a light which allows us to mask out the image in the shape of the picture frame.

Each image in the game will need all these nodes, all the setup of each of these will be the same. The only thing that will change is the content. Godot will allow us to instance this scene into another which is very powerful. Whenever we have to make changes to this template, all of it instances will change along with it.

This is an instance of that template. As you can see the nodes are greyed out meaning its settings are coming from the template. The cool thing about this is we can still change stuff here. In this case we want to use a different picture. We can simply use another image, all the functionality of the scene remains in tact. You can see that in the broader perspective this is super convinient. Whenever we create a new level, we only need to import new images. The template will make sure the masking happens, the script inside the scene will make sure all interactions work and the picture will contain the right text.

Level Scene

The level scene is the most important scene. It functions as a orchestrator for the entire game. In here everything will come together. How it exactly does that will follow in another blog, lets focus on the structure for now.

This is the level scene. As you can see the Parent node is called Country. It contains a few placeholder nodes for content. It also has a GUI scene node, Traveller Scene node, a camera and a map sprite. You might have noticed the little film icon behind GUI and Traveller. This icon means the node is an instanced scene. Starting to see the picture here? We have isolated bigger functionality into its own scenes to better control everything and keep things organised.

The Country scene as shown is also a template. To see how it all comes together have a look at the first level to be playable soon. The Netherlands.

This is the Netherlands level. It’s an instance of the Country scene. It now also contains some unique instanced child nodes of its own. The dropzones and images are visible here within their organiser nodes. All of them are instances as you can see. Adding them to the scene is done manually, they need proper placement and some design setup. Also as you can see, we now have a map which is a new sprite being placed into the Map sprite node.

New level

To conclude, this project setup allows me to setup a new level quite quickly. All I need to do for a entirely unique and new level is:

  • Create instances from the image template and add the images to it
  • Instance a new country scene
  • Instance in the image scenes
  • Instance in the dropzones
  • Add the new map
  • Put the dropzones on the right location on the map
  • Give each dropzone and image a match_id via an exported dropdown menu

And that’s it., a completely new and playable level. The scripts and the templates will take care of the heavy lifting, no addictional scripting is required.

It the next devlog, I’ll dive into some code stuff. See you soon !

Leave a Reply

Your email address will not be published. Required fields are marked *