Skip to main content
Godot Fundamentals – Complete Beginner to Advanced Guide
CHAPTER 20 Beginner

Build a Complete Indie Game with Godot

Updated: May 16, 2026
45 min read

# 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 CharacterBody2D that can run, jump, and attack using an AnimationPlayer.
  • Environment: A 2D level built rapidly using a TileMap and a ParallaxBackground.
  • Enemy: A patrolling slime that damages the player on contact.
  • Combat: The player can swing a sword (Area2D) to destroy the slime.
  • UI: A CanvasLayer HUD showing player health.
  • Goal: A collectible crystal that, when touched, displays a "You Win" screen.

3. Step 1: Project Setup and Environment

  1. 1. Create a new Godot project using the Compatibility renderer.
  1. 2. Go to Project Settings -> Window -> Stretch. Set Mode to canvasitems and Aspect to keep.
  1. 3. Create the Main Level: Node2D named World. Save it.
  1. 4. Add a TileMap node. Create a new TileSet. Use a simple square graphic to quickly paint a floor and a few floating platforms.
  1. 5. Add a ParallaxBackground with a dark blue ColorRect to act as the night sky.

4. Step 2: The Player Character

  1. 1. Create a new Scene: CharacterBody2D named Player.
  1. 2. Add a Sprite2D (use the Godot icon or a downloaded sprite), and a CollisionShape2D (Capsule).
  1. 3. Add a Camera2D to follow the player. Enable Position Smoothing.
  1. 4. Attach a script to the Player using the "Basic Movement" template. This automatically generates the gravity, jumping, and WASD running code.
  1. 5. Instance the Player into your World scene. Hit Play and ensure you can run and jump on the TileMap!

5. Step 3: Combat Mechanics (The Sword)

  1. 1. In the Player scene, add a Node2D named WeaponPivot.
  1. 2. As a child of WeaponPivot, add an Area2D named SwordHitbox with a CollisionShape2D (Rectangle) placed directly in front of the player.
  1. 3. In the Inspector, set the SwordHitbox Collision Mask to Layer 2 (Enemies).
  1. 4. Add an AnimationPlayer. Create an "Attack" animation that briefly enables the SwordHitbox collision, and then disables it.
  1. 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. 1. Create a new Scene: CharacterBody2D named Slime.
  1. 2. Set its Collision Layer to 2 (Enemy).
  1. 3. Add a Sprite2D and a CollisionShape2D.
  1. 4. Add an Area2D named Hurtbox around the Slime to detect sword hits.
  1. 5. In the Slime script, write basic patrol logic (move left until hitting a wall, then reverse direction using isonwall()).
  1. 6. Connect the Hurtbox's areaentered signal. If the overlapping area is named SwordHitbox, call queuefree() to kill the slime.
  1. 7. Instance a few Slimes into the World scene.

7. Step 5: Player Health and UI

  1. 1. In the Player script, add var health = 3. Create a takedamage() function that reduces health and prints "Ouch!".
  1. 2. In the Slime scene, add an Area2D named DamageZone. If a body enters it, and body.name == "Player", call body.takedamage().
  1. 3. Create a CanvasLayer scene named HUD. Add an HBoxContainer with three heart icons (TextureRect).
  1. 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. 1. We need "Juice." Create a GPUParticles2D scene named DeathExplosion.
  1. 2. Set it to One Shot, Explosiveness 1.0, and configure the material to shoot red particles in a 360-degree spread.
  1. 3. In the Slime script, right before queuefree(), instantiate the DeathExplosion at the slime's global position. Now enemies explode into pixels when struck by the sword!
  1. 4. Add an AudioStreamPlayer to play a "hit.wav" sound when the explosion occurs.

9. Step 7: The Win State

  1. 1. Create a new Scene: Area2D named Crystal.
  1. 2. Add a Sprite2D (a shiny gem) and a CollisionShape2D.
  1. 3. Add an AnimationPlayer to make the gem float up and down endlessly using a looped animation.
  1. 4. Connect the body_entered signal.
  1. 5. In the script:
python
12345
func _on_body_entered(body):
    if body.name == "Player":
        print("You Win!")
        # Use get_tree() to transition to a WinScreen UI scene
        get_tree().change_scene_to_file("res://WinScreen.tscn")
  1. 6. Place the Crystal at the end of your TileMap level.

10. The Final Playtest

  1. 1. Hit Play.
  1. 2. Run across the TileMap using the physics character controller.
  1. 3. Avoid the patrolling Slimes. If you touch them, watch your HUD lose a heart.
  1. 4. Click the mouse to swing your sword. Watch the Slimes explode into GPU particles and play a sound effect.
  1. 5. Navigate the platforms, reach the end of the level, and touch the floating crystal.
  1. 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.

Finish this Chapter

Save your progress on your learning path and prepare for coding interview challenges.

Discussion

Join the discussion

Log in or create a free account to participate.

Sort: ·