Skip to content

Foundations — GDScript & Godot 2D

What this is. A prerequisite track for two project-based Godot textbooks — the Emberdelve ARPG book and the idle-game book. Those books teach Godot and game design by building a game; they deliberately do not teach the GDScript language or the Godot engine model they stand on. The ARPG book says so outright: "The book does not re-teach programming fundamentals; it teaches Godot and ARPG design." This book fills exactly that gap, to the same standard, so that when you open those books you are working on them — reading code you understand and writing code you can defend — rather than copying steps.

The book has two parts:

  • Part A — GDScript: the language. The syntax and semantics of GDScript itself.
  • Part B — Godot 2D: the engine. The editor, the node and scene model, and the 2D runtime.

Who this is for, and what it assumes

This is not "intro to programming." It assumes you already program — that you know what a variable, a loop, a function, and a class are in some language. It does not re-explain those concepts. What it teaches is the delta: GDScript's specific syntax and semantics (static typing with inference, value-versus-reference types, the built-in value types, the script-is-a-class model, signals, the @export/@onready annotations) and the Godot engine model that no game tutorial slows down to explain. Where a construct differs from what you would expect coming from another language, the book names the difference and the reason for it.

A note on register: where a Godot concept maps onto a test-design idea — types as a parse-time contract, value/reference aliasing as a defect class, signals as test seams, save state as untrusted input — the book names the test-design idea. If you come from QA, those names are load-bearing, not decoration.

What this book teaches, and what it leaves to the game books

This book teaches mechanics: what a construct is and how to use it. The game books teach architecture: why and where to use it. The boundary is deliberate and strict.

  • This book teaches how to declare, emit, and connect a signal. The ARPG book keeps the SignalBus pattern built from them.
  • This book teaches Area2D overlap and the difference between a collision layer and a mask. The ARPG book keeps the Hurtbox / Hitbox / Health component architecture built from them.
  • This book teaches enum, match, and child nodes. The ARPG book keeps the node finite-state machine built from them.

So the finite-state-machine pattern and the component architecture are out of scope here — you meet them in the game books, already holding every mechanic they are assembled from.

How the book is structured

Each chapter follows the same shape: What you'll learnHow it applies (the real-world defect or consequence the construct guards against) → Concepts with worked examples → Walkthrough you perform yourself in Godot → a self-check quiz (answers hidden behind reveals) → an integration question that ties the chapter together → a glossary (hover any defined term). Code is built up incrementally across a chapter; you type it, because typing is part of how it lands — there are no finished scripts to paste.

The modules

Module What it covers Representative ground
L1 Syntax & semantics The language surface Types, control flow, functions, collections, vectors
L2 Classes, types & the object model GDScript's object model extends, class_name, properties, @export, enums, signals
G1 The editor, the tree & project data The Godot project model Editor, nodes, SceneTree, scenes, instancing, autoloads, Resources
G2 The 2D runtime The running game Lifecycle, transforms, 2D nodes, UI, input, signals, bodies, debugging

The hand-off contract

"Enough to work on the game books" is a testable claim, not a vibe. Every concept the game books assume at their start maps to a chapter here. A few representative rows:

Game-book chapter assumes… …taught in Foundations
ARPG M1.4 — SignalBus signal/emit/connect (L2.3), autoloads (G1.5), node lifecycle (G2.1)
ARPG M2.1 — movement _physics_process/delta (G2.1), Vector2 math (L1.6), Input (G2.5), CharacterBody2D/move_and_slide (G2.7)
ARPG M2.4 — node FSM enum/match (L1.3), class_name/is (L2.1), child nodes (G1.2), signals (L2.3, G2.6)
ARPG M3.1 — hitbox/hurtbox Area2D + layers/masks (G2.7), as casting (L2.1)
ARPG M5/M6 — StatBlock, ItemData custom Resource + @export (G1.6, L2.2)
Idle M1.4 — main layout Control, containers, anchors, size flags (G2.4)
Idle M2.1 — click button Button.pressed, @onready, %-format strings (G2.6, L1.2)
Idle M3.1 — tick accumulator _process/delta (G2.1), autoloads (G1.5)

The full matrix closes the final chapter (G2.8).

Prerequisites

  • Godot 4.6 installed (the book targets 4.6; 4.6.3 is the current stable point release). Download from godotengine.org.
  • Working comfort with variables, functions, loops, classes, and basic types in some language. The book teaches GDScript and Godot, not programming from zero.
  • A new, empty Godot project to experiment in. Part A runs scripts in that project with almost no scene setup; Part B builds out the editor and 2D scene work in full.

Begin with L1.1 — Your first script & running it in the sidebar.