Build a Complete Indie Game with Godot
# CHAPTER 20
Build a Complete Indie Game with Godot
1. Introduction
You have spent 19 chapters learning the mechanics of the Godot Engine. You understand Nodes, GDScript, Physics, UI, and AI. However, reading about a hammer does not build a house. True mastery only comes when you combine all these disparate systems into a cohesive, playable experience. In this final chapter, we will build the Capstone Project: "The Crystal Knight." This will be a complete vertical slice of a 2D action-platformer featuring a controllable hero, hostile AI, combat mechanics, a functional HUD, and a win-state. It is time to make a game.2. Project Requirements
The game will feature:-
Player: A
CharacterBody2Dthat can run, jump, and attack using anAnimationPlayer.
-
Environment: A 2D level built rapidly using a
TileMapand aParallaxBackground.
- Enemy: A patrolling slime that damages the player on contact.
-
Combat: The player can swing a sword (
Area2D) to destroy the slime.
-
UI: A
CanvasLayerHUD showing player health.
- Goal: A collectible crystal that, when touched, displays a "You Win" screen.
3. Step 1: Project Setup and Environment
- 1. Create a new Godot project using the Compatibility renderer.
-
2.
Go to Project Settings -> Window -> Stretch. Set Mode to
canvasitemsand Aspect tokeep.
-
3.
Create the Main Level:
Node2DnamedWorld. Save it.
-
4.
Add a
TileMapnode. Create a newTileSet. Use a simple square graphic to quickly paint a floor and a few floating platforms.
-
5.
Add a
ParallaxBackgroundwith a dark blueColorRectto act as the night sky.
4. Step 2: The Player Character
-
1.
Create a new Scene:
CharacterBody2DnamedPlayer.
-
2.
Add a
Sprite2D(use the Godot icon or a downloaded sprite), and aCollisionShape2D(Capsule).
-
3.
Add a
Camera2Dto follow the player. EnablePosition Smoothing.
- 4. Attach a script to the Player using the "Basic Movement" template. This automatically generates the gravity, jumping, and WASD running code.
-
5.
Instance the
Playerinto yourWorldscene. Hit Play and ensure you can run and jump on the TileMap!
5. Step 3: Combat Mechanics (The Sword)
-
1.
In the
Playerscene, add aNode2DnamedWeaponPivot.
-
2.
As a child of
WeaponPivot, add anArea2DnamedSwordHitboxwith aCollisionShape2D(Rectangle) placed directly in front of the player.
-
3.
In the Inspector, set the
SwordHitboxCollision Mask to Layer 2 (Enemies).
-
4.
Add an
AnimationPlayer. Create an "Attack" animation that briefly enables theSwordHitboxcollision, and then disables it.
- 5. In the Player script, listen for the "Attack" input (e.g., Mouse Click) and play the animation.
6. Step 4: The Enemy Slime
-
1.
Create a new Scene:
CharacterBody2DnamedSlime.
- 2. Set its Collision Layer to 2 (Enemy).
-
3.
Add a
Sprite2Dand aCollisionShape2D.
-
4.
Add an
Area2DnamedHurtboxaround the Slime to detect sword hits.
-
5.
In the Slime script, write basic patrol logic (move left until hitting a wall, then reverse direction using
isonwall()).
-
6.
Connect the
Hurtbox'sareaenteredsignal. If the overlapping area is namedSwordHitbox, callqueuefree()to kill the slime.
-
7.
Instance a few Slimes into the
Worldscene.
7. Step 5: Player Health and UI
-
1.
In the
Playerscript, addvar health = 3. Create atakedamage()function that reduces health and prints "Ouch!".
-
2.
In the
Slimescene, add anArea2DnamedDamageZone. If a body enters it, andbody.name == "Player", callbody.takedamage().
-
3.
Create a
CanvasLayerscene namedHUD. Add anHBoxContainerwith three heart icons (TextureRect).
- 4. Write a script on the HUD to listen for a global signal from an Autoload, updating the heart graphics when the player loses health.
8. Step 6: Visual Polish and Particles
-
1.
We need "Juice." Create a
GPUParticles2Dscene namedDeathExplosion.
- 2. Set it to One Shot, Explosiveness 1.0, and configure the material to shoot red particles in a 360-degree spread.
-
3.
In the
Slimescript, right beforequeuefree(), instantiate theDeathExplosionat the slime's global position. Now enemies explode into pixels when struck by the sword!
-
4.
Add an
AudioStreamPlayerto play a "hit.wav" sound when the explosion occurs.
9. Step 7: The Win State
-
1.
Create a new Scene:
Area2DnamedCrystal.
-
2.
Add a
Sprite2D(a shiny gem) and aCollisionShape2D.
-
3.
Add an
AnimationPlayerto make the gem float up and down endlessly using a looped animation.
-
4.
Connect the
body_enteredsignal.
- 5. In the script:
- 6. Place the Crystal at the end of your TileMap level.
10. The Final Playtest
- 1. Hit Play.
- 2. Run across the TileMap using the physics character controller.
- 3. Avoid the patrolling Slimes. If you touch them, watch your HUD lose a heart.
- 4. Click the mouse to swing your sword. Watch the Slimes explode into GPU particles and play a sound effect.
- 5. Navigate the platforms, reach the end of the level, and touch the floating crystal.
- 6. Watch the game transition to the Victory screen!
11. Your Journey Continues
Congratulations! You have successfully built a complete vertical slice of an indie game. You have transformed abstract coding concepts into a living, interactive world.The Godot Engine is now a tool firmly in your grasp. From here, the path is yours. Participate in Game Jams (like Ludum Dare or the GMTK Game Jam) to force yourself to build small games rapidly. Read the official Godot Documentation. Experiment with 3D.
Game development is a journey of lifelong learning, problem-solving, and creativity. You have the engine. You have the knowledge. Now go build the game you've always dreamed of playing.
Course Complete.