Godot & the Game Loop

Godot Fundamentals

Chapter 1 · Godot & the Game Loop

Godot is a free, open-source game engine, and the tool this entire course is built around. Before writing a single line of GDScript, this chapter covers the two ideas everything else depends on: how Godot organises a game as a tree of Nodes, and how the game loop actually runs, frame by frame.

What Is Godot?

Godot is released under the MIT licence — genuinely free, with no royalties, even for a commercial game you go on to sell. As of this writing the current stable release is Godot 4.7, and the engine ships as a single executable rather than a heavy installer.

Free & open source

MIT licensed. No subscription, no revenue share, no per-seat cost — for a hobby project or a commercial release alike.

GDScript

Godot's own built-in scripting language — deliberately close to Python's own syntax, covered fully in Chapter 2.

2D and 3D

One engine handles both. This course focuses on 2D, since it's the faster, more forgiving place to actually learn the fundamentals.

Installing Godot

  1. Download the current stable build from godotengine.org/download for your platform.
  2. Unlike many game engines, there's no installer to run — the download is a single executable file.
  3. Run it directly. Godot opens straight into the Project Manager, where you create or open a project.
No install step, genuinely — you can keep multiple Godot versions side by side as separate files with no conflict, which matters more than it sounds once you're following tutorials written against slightly different versions.

The Node & Scene Paradigm

Everything in Godot is a Node. A sprite is a node. A sound player is a node. A camera is a node. A collision shape is a node. Each node type is a small, focused component that handles exactly one job.

Nodes are arranged in a tree — a parent can have any number of children, but every node has exactly one parent (except the root). This tree of nodes is called a scene, and a scene is typically saved as its own file so it can be reused — a player character, an enemy, a whole level can each be their own scene.

Moving or deleting a parent affects everything beneath it — exactly like a folder and the files inside it. This is a deliberate, useful property of the tree, not a gotcha, but it's worth having in mind from the very first scene you build.

A first scene, conceptually

A simple player character scene might look like this: a Node2D as the root (giving the whole thing a position, rotation, and scale), with a Sprite2D child (the visible image) and a Camera2D child (so the view follows the player). Three specialised nodes, each doing one job, combined into one reusable scene.

Scripts & the extends Keyword

A script attaches behaviour to a node. Every GDScript script starts by declaring which node type it extends — meaning the script's own code effectively becomes part of that node, with access to everything that node type already provides.

extends Node2D # Called once when the node enters the scene tree for the first time. func _ready() -> void: print("Hello, Godot!")

_ready() is one of Godot's own built-in lifecycle functions — it runs exactly once, the moment this node is fully set up in the scene tree. It's a natural place for one-time setup, but it isn't the game loop itself — that's covered next.

The Game Loop — _process vs. _physics_process

Godot calls two special functions repeatedly, for as long as the game runs, and the difference between them matters a great deal.

FunctionRunsUse it for
_process(delta) Every rendered frame — rate can vary with performance UI updates, animation, general logic, reading input for an immediate response
_physics_process(delta) A fixed rate, independent of rendering framerate Movement, collisions, anything using move_and_slide() — physics needs a consistent, predictable timestep

Both functions receive a delta parameter — a floating-point number representing how much time has passed since the last call, typically around 0.0167 seconds at 60 frames per second.

extends Node2D var speed = 200.0 func _physics_process(delta): # Move 200 pixels per SECOND, not 200 pixels per FRAME. position.x += speed * delta
Always scale movement by delta — moving a fixed number of pixels per call, with no delta involved, would make the game run faster or slower depending purely on how fast the player's own machine happens to render frames. Multiplying by delta is what makes movement frame-rate independent.
Coming from Python GDScript's own syntax was deliberately modeled on Python — indentation-based blocks, a similar func/def feel, and no semicolons. If you've worked through this site's own Python courses, GDScript will feel immediately familiar in a way most other scripting languages won't. The real differences show up in Chapter 2: GDScript is optionally statically typed, and it has Godot-specific building blocks — nodes, signals, scenes — that Python's own standard library has no equivalent for.

Coding Challenges

Challenge 1
Install Godot and create a new project. Add a Node2D as the scene's root, save the scene, and run it (even with nothing visible yet — the goal is confirming your setup works end to end).
→ Solution
Challenge 2
Build a small scene tree by hand: a Node2D root named "Player," with a Sprite2D child and a Camera2D child. Inspect the tree in Godot's own Scene panel and explain, in your own words, why each node is a separate child rather than one combined node.
→ Solution
Challenge 3
Attach a script extending Node2D to your root node. Implement both _process(delta) and _physics_process(delta), each printing its own delta value, and run the scene to compare how often each one actually fires.
→ Solution

Quick Reference — Godot & the Game Loop

  • Godot: free, MIT licensed, single-executable install, current stable release 4.7
  • Everything is a Node; a tree of Nodes is a scene
  • A script extends a node type, becoming part of that node
  • _process(delta): every rendered frame, variable rate — UI, general logic
  • _physics_process(delta): fixed rate — movement, collisions
  • Always scale movement by delta for frame-rate independence