Let’s Learn Godot 4 by Making a Procedurally Generated Maze Game— Part 1: Project Overview & Setup 💣

Christine Coomans
8 min readSep 27, 2023

--

I grew up in the era where PlayStation reigned supreme as the be-all and end-all of gaming. It felt as if almost everybody owned a PS1 or PS2, and I even still have my old consoles to this day. But there was a time before its reign when I was too young to be allowed to handle the expensive, fragile, and scratch-ready disks of a PlayStation console — and so my parents bought me and my sister a more durable (no-name console) that used cassettes instead of CDs.

Figure 1: A generic cassette gaming console, cassettes, and a classic box-tv

These cassettes came with what felt like hundreds of games, but no game entertained me as much as Bomberman. If you have never played Bomberman, it essentially is a maze-like game where players (single or multiplayer) run around the map to strategically place bombs that damage and remove obstacles, enemies, other players, and even themselves. If the player stays alive and successfully removes all enemies and other players (well before the 2-minute timer runs out) the level is complete, and the player gets to continue to the next level.

Figure 2: Bomberman II preview. This version was released in 1991 on Nintendo.

Now, you’re not reading this to hear about the history of Bomberman or my childhood — no, you’re reading this because you want to learn how to make a procedurally generated game — so let’s get started.

PROJECT OVERVIEW

What is Procedural Generation?
Procedural generation refers to a computer algorithm that automatically creates content based on pre-written instructions.

We are going to make a procedurally generated game like Bomberman where our game will automatically take care of the map generation and entity spawning for each level. This means we won’t have to manually create our map for each level, and we also don’t have to set up and manage the spawn points for our players, enemies, and pickups.

If you are curious, here is a short video of our final project’s gameplay so that you can get an idea of what it will look like at the end.

You can also play the demo of our end product here.

Let’s break up the outline for our project:

GAME MODES

  • We will have two game modes: normal and battle mode.
  • In normal (single-player) mode, the player will have to stay alive and bomb all enemies on the map before the timer runs out.
  • In battle (multiplayer) mode, the player will choose up to 3 AI players to join. These AI players will help the player take out the enemies on the map. After all the enemies are removed, the AI players will then chase and attack the player and so the player will have to stay alive and remove all the AI’s on the map before the timer runs out.

LEVEL & MAPS

  • The game will be level based. Each level will increase the enemy count, boost spawning, and map size autonomously. Each level also runs with a five-minute timer.
  • Each level’s map will be generated procedurally — which means it will be generated at random on every load. Each time the level count increases, the map will automatically generate a bigger map with dynamically placed obstacles, enemies, and pickups.

PLAYER & AI PLAYERS

  • The player has three lives, whereas the AI Player only has one life. The player can be damaged by AI players, enemies, and their own bombs. The AI player can only be damaged by the player.
  • AI Players and the Player will spawn randomly in one of the four spawn points of the generated map — which will be located in the corners. AI Players and the Player will also spawn randomly with a randomly chosen color.
  • The player and AI Players can pick up explosion boosts, which will increase the explosion radius of their bombs for 10 seconds. They can only increase their explosion radius three times — so they can have a small, medium, and large explosion.
  • The player is controlled by us, whereas the AI Players will follow a path to the nearest enemy, and if there are no enemies left, they will chase the player.

ENEMIES

  • Enemies will roam randomly on the map.
  • Each level will increase the number of enemies by 2 (level 1 = 1, level 2 = 3, level n = n). Different enemies of different difficulties will spawn on these levels.
  • Orange enemies deal 1x damage to the player.
  • Blue enemies deal 2x damage to the player.
  • Green enemies deal 3x damage to the player.
Figure 3: Overview of our BomerClone game.

PROJECT SETUP

Since the definition of an Intermediate developer is subjective and we will be covering somewhat complex concepts, I will try to explain everything in this tutorial series in the best way possible, so even if you are leaning more towards the beginner side of “Intermediate” you’ll still be able to follow along and understand what’s going on. All the necessary documentation will also be linked throughout the tutorial series, and the project files for the respective parts can be found at the end of each section.

This project is made in Godot version 4.1.1, which is the latest version of Godot as per this series’ release, but I will try to make amendments and additions to the project as needed when newer versions are released. If you use a newer version, you may encounter bugs that I have not fixed/found yet — so either try and troubleshoot it yourself first, or let me know and I will revise the project.

Open up Godot, and in the Project Manager window, create a new project. Give the project a name of your choice (I called mine “BomerClone”) and save it in a directory where you will be able to easily find and manage it. In terms of the renderer, you can choose either Forward+ or Compatibility mode since it does not matter — we’re creating a 2D game, not a 3D game that requires fast rendering of lighting.

With your Project Window open, navigate down to the FileSystem Panel below and create four new folders:

  • Scenes: This will contain all of our .tscn scene files.
  • Scripts: This will contain all of our .gd code files.
  • Resources: This will contain our TileSet resource for our TileMap.
  • Themes: This will contain our saved themes and styles for our UI.

Next, download the Assets folder and drag it into your FileSystem Panel. You can find all the credits for the sourced assets here if you want to view other work from the creators or if you want to support them.

Open up your Project Settings, and underneath Renderer > Textures, change the default texture filter from “Linear” to “Nearest”. Our game will be created mostly with pixel art, and thus Nearest filtering preserves the original pixel values of our CanvasItems and Sprites without averaging them — leading to them looking clearer and sharper, especially when scaled. Linear filtering can blur these details, making our sprites look less sharp.

What is texture filtering?

Texture filtering is a technique used in computer graphics to improve the appearance of textures when they are applied to 3D models or 2D images. It becomes particularly important when a texture is scaled, rotated, or otherwise transformed.

Choosing the correct texture filtering mode is essential for improving image quality, performance, and the overall visual experience in both 2D and 3D graphics.

Then, in your Display > Window screen, change the stretch mode to “canvas_items”. In this mode, the base size specified in width and height in the project settings is stretched to cover the whole screen. This means that everything is rendered directly at the target resolution. This will come in useful later on when we generate our map and add our camera to our player.

Finally, let’s add our Inputs for our game, which will allow the player to navigate and interact with the game. With your Project Settings menu still open, navigate to Input Map and enable the “Show Built-In Actions” toggle. We want to map our WASD keys to our ui_left, ui_right, ui_up, and ui_down input actions.

We will also create two new Input Actions that our player will use later on to drop bombs and pause the game. The functionality for these inputs will be added later on, but for now, we will add two new actions called “ui_pause” and “ui_drop_bomb”. I’m following the naming conventions of the pre-configured input actions, but you can omit the ui_ if you want.

Assign the SPACE key on your keyboard to your ui_drop_bomb input, and the ESC key to your ui_pause input. You can also change these inputs to other keys or controller buttons if you’d like.

And that is our Project Setup complete. We do not have any Scenes yet, but that will change in the next part when we create our Player character and add its movement. I strongly encourage you to create a backup folder on your computer or a GitHub repository to make regular backups of your project after each Part.

Figure 4: Example of a GitHub repository.
  • You can also use the official Git Plugin from Godot, but as of July 2023, the Git plugin hasn’t been updated to work with Godot 4.1 and later yet.

Unlock the Series!

If you like this series and would like to support me, you could donate any amount to my KoFi shop or you could purchase the offline PDF that has the entire series in one on-the-go booklet!

This PDF gives you lifelong access to the full, offline version of the “Learn Godot 4 by Making a Procedurally Generated Maze Game” series. This is a 387-page document that contains all the tutorials of this series in a sequenced format, plus you get dedicated help from me if you ever get stuck or need advice. This means you don’t have to wait for me to release the next part of the tutorial series on Dev.to or Medium. You can just move on and continue the tutorial at your own pace — anytime and anywhere!

This book will be updated continuously to fix newly discovered bugs, or to fix compatibility issues with newer versions of Godot 4.

--

--

Christine Coomans
Christine Coomans

Written by Christine Coomans

Just a *redacted* trying to human. 👾Visit my website for more cool resources: https://christinecdevs.site

No responses yet