Looting! Module overview

Welcome to Looting! In this module, you will build upon what you learned so far. You will create a chest you can interact with using the mouse (or touch on touchscreens) and that spawns loot.
You will learn how to:
  • Detect mouse input with Area2D nodes: The mouse entering and exiting the area, and clicking over the area. You will reuse this in mobile games, point-and-click adventures, RPGs, and more.
  • Use a provided shader asset and change its values to show the chest is interactable on hover.
  • Use "onready" variables to store references to nodes.
  • Use the @export annotation to export script variables to the Inspector and easily change their value.
We'll also review areas, tween animation, randomness, signals, and more.
There are different ways to check for input in Godot, including mouse input. We'll see two of them in this module:
  1. The _input_event() function Godot provides to check clicks over collision shapes.
  2. The mouse_entered and mouse_exited signals to know when the cursor enters or leaves an area.
This project will help you solidify your understanding of areas. We will also take this opportunity to use shaders for the first time.
Shaders are programs that run on the computer's graphics card to produce visual effects like adding an outline around a sprite, making things glow, faking reflections in a water puddle, and more. You can find more details in the glossary: shaders.
Learning to code shaders is its own math-heavy domain and is beyond the scope of this course. Thankfully, there are many free and open-source shaders you can use (for example, here's an open-source library we made), and it's very common to use shaders made by others in games because of the unique technical knowledge they require.
In this module, we will use a shader to draw an outline around the chest that grows when hovering over it with the mouse. We will make the outline grow and shrink smoothly by using Tween Animations
Tweens are code-driven animations we use to change a value over time.Tween Glossary Entry
. Most importantly, we will do our first guided experimentation session in this module. We will see how you can play with the code you wrote in the module, tweak it, build upon it, and make it a bit more yours.
This kind of practice is often absent from tutorials, and it's a key reason why you usually find yourself unable to apply most of what you learned to your projects. Experimentation will make you step from the Copy learning stage to Customize and even Create: The 3Cs of learning to code and make games.

Download the project files

If you don't have the files for this module yet, you can download them from the link below. Click the link corresponding to your operating system:
This will download a ZIP file with everything you need to follow the lessons and interactive practices. For detailed instructions on how to use the project files, check out the page Get to Know Godot.
Let's start by opening the project and reviewing the workbook for this module.

Open and review the workbook for this module

Open the Godot project M6. Looting! (Workbook).
The workbook project selected in the Godot project manager
When you open the project, you land on the mini-dungeon scene. It's a small "room" with a tilemap, some pillars, and torches on the wall. The scene contains a Background node in which you will find the many nodes that compose the environment, like the TileMap used to draw the dungeon, the pillar sprites, and the torches hung on the wall.
The mini dungeon scene in the Godot editor
The Background node is a Node2D, a node with a position, rotation, and scale in the 2D space. We use it to group all the background nodes together and keep the scene organized.
You can fold the Background node by clicking the chevron icon in the Scene dock at the top left.
The Background node folded in the Scene dock
Will we learn to make environments like this in the course?
Yes! Later in the course, we will have lessons dedicated to setting up a tileset and using it to draw your own level.
We limit the number of concepts taught in each module to spread the load and build important gamedev and Godot concepts on top of one another. That's why tilesets and tilemaps will come later.
Now, look at the lessons folder in the FileSystem dock. Double-click it to open the folder.
The lessons folder in the FileSystem dock
In it, you will find the mini_dungeon.tscn scene file. It's the project's main scene, the scene that runs when pressing f5 (on Mac: b), which is open in the viewport by default. You will also find two directories for the chest and the items.
In the chest folder are three images we will use to draw the chest and the outline shader mentioned previously, group_outline.gdshader. This shader draws an outline around sprites, and we'll see how to use it in the next lesson.
The chest folder in the FileSystem dock
The items folder has three items with the same code as in the previous module. The difference is that this time, there are three items: A potion, an apple, and a key. It's only the visuals that change, which is why we provide the scenes premade.
The items folder in the FileSystem dock
You will find more files in the assets folder at the file system's root, but we'll look at them as we need them.
Now you got an overview of the project's starter files, we can get started creating the chest. In the next lesson, we will build the chest and code the outline that appears on hover. See you there!

Lesson Q&A

Use this space for questions related to what you're learning. For any other type of support (website, learning platform, payments, etc...) please get in touch using the contact form.

  • Basic 2D forms spritesploped00Hi all! In Unity, you can create basic 2D forms (squares, circles...) directly in the editor, without needing to add them as sprites. As far as I currently know, in Godot you have to add them as Sprite2D nodes. My question is...is there any good repository to download this basic sprites? (e.g. the sprite named "small_circle.png" you added into the project folder) Thanks in advance! 2 1 Jun. 27, 2024
  • Windows Archive has 0.3.3 in name, but folder in it is 0.3.2TristanchikSubj 1 0 May. 05, 2024
Site is in BETA!found a bug?