
set up a Godot 4 project, build a scene from nodes, write a GDScript that moves a sprite with the keyboard at a speed that does not depend on the frame rate, and organize, import and back up the project’s files.
Instruction
Every game engine answers the same question: how do you describe a world, and how do you tell it what to do each moment? Godot 4 answers with two ideas, nodes and scenes. (This lesson’s build is adapted from the Godot documentation’s “Nodes and scenes” and “Creating your first script” pages, by Juan Linietsky, Ariel Manzur and the Godot community, CC BY 3.0.)
Nodes. A node is one building block with one job. A Sprite2D draws an image. A Camera2D decides what part of the world is on screen. A Timer counts down. An AudioStreamPlayer plays a sound. Nodes are arranged in a tree: each node can have children, and children move with their parent. If you move a spaceship node, its flame sprite and its engine sound come along.
Scenes. A scene is a saved tree of nodes, stored as a .tscn file. A player can be a scene; so can a coin, a level or a whole menu. Scenes can be placed inside other scenes, which is how a level fills up with fifty coins that all behave the same way. When you run the game, Godot runs one main scene, and everything else hangs from it.
Scripts. A script attached to a node gives it behavior. Godot’s own language, GDScript, reads like Python: indentation shows which lines belong together, and there are no semicolons. Every script begins with extends and the node type it controls. Here is the script you will write today:
extends Sprite2D
@export var speed: float = 200.0
func _process(delta: float) -> void:
var direction := Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
position += direction * speed * delta
if Input.is_action_pressed("ui_accept"):
rotation += 2.0 * deltaRead it line by line. @export var speed: float = 200.0 makes a variable that holds a decimal number and shows it in the Inspector, so you can tune it without editing code. _process(delta) is a function Godot calls once every frame. Input.get_vector reads the four arrow keys and returns a direction: pressing right gives (1, 0), pressing up gives (0, −1), because in Godot’s 2D coordinates y grows downward. The last two lines spin the sprite while Space or Enter is held.
Why multiply by delta? delta is the time since the last frame, in seconds. At 60 frames per second it is about 0.0167 s, so the sprite moves 200 × 0.0167 ≈ 3.3 pixels per frame. On a slower computer running at 30 frames per second, delta is 0.0333 s and the sprite moves about 6.7 pixels per frame. Either way it covers 200 pixels each second. Without delta, the game would run twice as fast on a fast computer as on a slow one, which is a bug players notice immediately.
Indentation matters. GDScript uses indentation to mark blocks, and the Godot editor indents with tabs. Type the code rather than pasting it; if you paste, check that every indented line uses the same kind of indentation, or Godot will report a “mixed tabs and spaces” error.
Files and where they live. A Godot project is a folder, and every file in it has a job shown by its extension. project.godot holds the project settings, .tscn files are scenes and .gd files are scripts. Godot also writes a small .import file beside each asset and keeps its import cache in a hidden .godot folder, which it rebuilds by itself. Assets you bring in are imported by type. Godot’s documentation lists raster images such as .png, .jpg, .webp, .bmp and .tga, vector images as .svg, and sound as .wav, .ogg (Ogg Vorbis) and .mp3. Working files from paint programs, such as GIMP’s .xcf, Krita’s .kra or Photoshop’s .psd, are not on those lists: export a .png copy and import that.
Downloading assets. Asset packs usually arrive as one .zip archive. Godot cannot use a file that is still inside an archive, so extract it, then copy only the files you need into your project folder (a subfolder named art keeps things tidy) and keep the pack’s license file with them. Kenney’s packs at kenney.nl are free and released under CC0; the download button offers a donation, and you choose “Continue without donating”. No account is needed, and you never need to pay for anything in this course.
Storage and backup. Your project lives on your computer’s internal drive, which is one copy: a failed drive, a spilled drink or a lost laptop takes it with it. Keep a second copy on a different device. A USB flash drive or external drive is the simplest route: close Godot, zip the whole project folder with the date in its name (firstname-first-scene-2026-11-10.zip), copy the ZIP to the drive, open the copy once to check it runs, then eject the drive before unplugging it so no file is left half-written. A cloud folder is a second route only if a parent or guardian has approved the service; never upload project files to a site a stranger suggests. Keep one dated backup per work session and delete only the oldest.
Work safely. Screen work is still physical work. Sit with your feet flat and the top of the screen at about eye level, keep cables off the walkway, and follow the 20-20-20 habit: every 20 minutes, look at something about 20 feet away for 20 seconds.
📖 Read for this lesson
The reading opens over the lesson; close it to come back to exactly where you were. The checks below draw on it.
Build: A sprite that answers the keyboard
Question. Can you build a scene from nodes and write a script so a sprite moves at the same on-screen speed whatever the frame rate?
Materials
- A computer with the Godot 4 desktop editor (version 4.3 or later, standard build) unzipped to a folder on your computer; no installation or account needed
- The icon.svg image every new Godot project includes, or one character sprite (.png) from a free Kenney asset pack (kenney.nl, CC0; choose “Continue without donating”; no account)
- Headphones (optional for this build) and a notebook or document for the build log
- A USB flash drive or external drive for backup (or a cloud folder a parent or guardian has approved)
- Set up ergonomically: feet flat, wrists straight, top of screen near eye level; use the 20-20-20 break habit during long builds.
- Keep power and USB cables tucked away from walkways and chair wheels.
- Save with Ctrl+S after every step, and zip a dated copy of the project folder at the end of the session and copy it to your USB drive, so a lost laptop never means lost work.
Procedure
- Open Godot and, in the Project Manager, create a new project named firstname-first-scene in a folder named game-design inside your Documents folder. Choose the Compatibility renderer, which runs on more machines and exports well to the web.
- In the Scene dock choose 2D Scene. Godot creates a Node2D root; rename it Main. Add a child node (Ctrl+A) of type Sprite2D and drag icon.svg (or a Kenney .png you extracted from the pack’s ZIP and copied into an art subfolder of the project) from the FileSystem dock onto its Texture property in the Inspector. Move the sprite near the center of the screen. Save the scene as main.tscn.
- Select the Sprite2D, click the Attach Script button, keep the default name and choose Create. Type the script from the lesson exactly, with tabs for indentation.
- Press F5 to run the project; when asked, choose Select Current to make main.tscn the main scene. Test the arrow keys and hold Space. Close the game window.
- Select the Sprite2D and change Speed in the Inspector to 100, then 400. Run each time and time how long the sprite takes to cross the window, which is 1152 pixels wide by default.
- Deliberately break it: delete “* delta” from the movement line, run, and describe what happens. Then restore it. Record each run in your build log (what you changed, what you predicted, what happened).
- Back up and check your files. Close Godot, open the project folder in your file manager and list in your build log each file type you see (.godot, .tscn, .gd, .svg or .png, .import) and what it is for. Zip the folder with today’s date in the name, copy the ZIP to your USB drive (or parent-approved cloud folder), open the copy in Godot to check it runs, and eject the drive before unplugging it.
Data
| Speed (px/s) | Predicted time to cross 1152 px (s) | Measured time (s) | Notes |
|---|---|---|---|
| 100 | 11.5 | ||
| 200 | 5.8 | ||
| 400 | 2.9 | ||
| 200, delta removed | ? |
Analysis
- Did your measured crossing times match 1152 ÷ speed? Give one reason a hand-timed measurement might differ.
- Explain in your own words what went wrong when you removed delta, and why a player on a different computer would see something different.
- Which node would you add next to make this feel like a game, and what would it do?
- Which file types in your project folder did you create, and which did Godot create for you? Why would a backup that left out the .gd file be useless?
If you cannot do this build in person: If the desktop editor cannot be installed on your device, open the Godot web editor (editor.godotengine.org) in a desktop Chrome or Edge browser, create the project there and follow the same steps; before you close the tab use the Project menu’s option to download or pack the project as a ZIP, because the web editor stores files only in that browser. If neither works, trace the script by hand: for delta = 0.0167 and delta = 0.0333, compute how far the sprite moves in one frame and in one second, and explain the result.
Formative check
Work through these before moving on. They are not graded — they tell you whether the standard below has landed yet.
Simulation & tools
Godot web editor (backup route)
Use this only if the desktop editor is unavailable. Open the link in desktop Chrome or Edge, choose Start Godot editor, create a new project with the Compatibility renderer, and complete steps 2-6 of the build. Before you close the tab, use the Project menu’s option to download or pack the project as a ZIP, because the web editor keeps files only in this browser. Record in your build log the speed you tested and the crossing time you measured. If you cannot use a computer at all, complete the hand-trace described in the build’s alternative instead.
Open Godot Engine web editor ↗ · Godot Engine web editor · MIT open source
A sprite has speed 300 px/s. At 60 frames per second, delta is about 0.0167 s, so the sprite moves about pixels per frame and pixels per second.
In Godot 2D, you press the up arrow and Input.get_vector returns (0, -1). Why negative?
You delete “* delta” from the movement line and run the game at 60 frames per second with speed 200. What happens?
Missouri standard: MM.FIL.1, MM.FIL.3
You downloaded a free asset pack as pixel-pack.zip. Which file can you use directly as a Sprite2D texture once you extract the archive and copy the file into your project folder?
Missouri standard: MM.FIL.5, MM.FIL.6
The only copy of your project is on your laptop. Which backup plan protects it best?
How confident are you that you can build a Godot scene from nodes and script frame-rate-independent movement?
Practice
Work these on paper or in your notebook, then open Check your answer. Aim for all of Fluency and Application; try at least one Challenge.
Printable version: this unit’s practice workbook (PDF)
Fluency
Build speed and accuracy with the core skill.
- Match each file to its job in a Godot project: project.godot, main.tscn, player.gd, coin.png.import.
Check your answer
Answer: project.godot holds the project settings; main.tscn is a scene; player.gd is a script; coin.png.import is the small file Godot writes beside an imported asset.The hidden .godot folder holds the import cache, which Godot rebuilds by itself. - In Godot 2D, what does Input.get_vector(“ui_left”, “ui_right”, “ui_up”, “ui_down”) return when only the left arrow is held? When only the down arrow is held?
Check your answer
Answer: Left: (−1, 0). Down: (0, 1).x grows to the right and y grows downward in Godot’s 2D coordinates, so left is negative x and down is positive y. - Which of these can you drag straight onto a Sprite2D’s Texture once they are in the project folder: hero.png, hero.kra, sprites.zip, logo.svg, hero.psd?
Check your answer
Answer: hero.png and logo.svg.Godot imports raster images such as .png and vector .svg. A .kra or .psd is a paint program’s working file: export a .png copy. A .zip must be extracted first.
Application
Use the skill in context. Show your reasoning.
- A sprite has speed 150 px/s. How far does it move in one frame at 60 frames per second (delta ≈ 0.0167 s)? At 30 frames per second (delta ≈ 0.0333 s)? How far in one second in each case?
Check your answer
Answer: About 2.5 px per frame at 60 fps; about 5.0 px per frame at 30 fps; 150 px per second either way.150 × 0.0167 ≈ 2.5 and 150 × 0.0333 ≈ 5.0. Per second: 2.5 × 60 = 150 and 5.0 × 30 = 150. That is why motion is multiplied by delta. - The default window is 1152 pixels wide. How long does a sprite moving at 320 px/s take to cross it?
Check your answer
Answer: 3.6 seconds.time = distance ÷ speed = 1152 ÷ 320 = 3.6 s. - Fix the bug. A student’s sprite races off-screen on a fast computer and crawls on a slow one:
func _process(delta: float) -> void:
var direction := Input.get_vector(“ui_left”, “ui_right”, “ui_up”, “ui_down”)
position += direction * speedCheck your answer
Answer: Change the last line to position += direction * speed * delta.Without delta the sprite moves speed pixels every frame, so its speed depends on the frame rate. Multiplying by delta (seconds since the last frame) turns it into pixels per second. - The lesson’s script spins the sprite with rotation += 2.0 * delta while Space is held. How much does the rotation value grow if you hold Space for 1.5 seconds?
Check your answer
Answer: 3.0 (radians).The line adds 2.0 per second because it is multiplied by delta, so 2.0 × 1.5 = 3.0. - Godot refuses to run a script and reports a “mixed tabs and spaces” error. What caused it, and how do you fix it?
Check your answer
Answer: Some indented lines use tabs and others use spaces, usually after pasting code. Re-indent every line the same way (the Godot editor uses tabs), ideally by typing the code.GDScript uses indentation to mark which lines belong together, so it must be one consistent kind.
Challenge
Stretch problems. Expect to think before you write.
- You want a sprite to cross the 1152-pixel window in exactly 4 seconds. What value should speed have, and what would the crossing time be if you then halved it?
Check your answer
Answer: 288 px/s; halving it to 144 px/s doubles the crossing time to 8 seconds.speed = 1152 ÷ 4 = 288. 1152 ÷ 144 = 8.
Review
Keep earlier skills sharp.
- Review (Lesson 1.1): in tic-tac-toe, which formal element are the empty squares, and why?
Check your answer
Answer: The resource: they are scarce, and both players compete to use them.A resource is whatever players must manage because there is not enough of it.
First Scene: Frame-Time Numbers, a Hand-Trace and a Sample Build Log
SLS original; Godot documentation quoted under CC BY 3.0 (Juan Linietsky, Ariel Manzur and the Godot Engine community); license per the Godot FAQ, read 2026-09-26 · SLS original; quoted Godot documentation is CC BY 3.0
Why this reading. The build asks you to script movement that does not depend on the frame rate and to keep a five-line build log; this sheet gives the numbers to check your work and a hand-trace for the no-computer route.
What the Godot documentation says
The Godot documentation (CC BY 3.0, attributed to Juan Linietsky, Ariel Manzur and the Godot Engine community) says that a scene is composed of one or more nodes and that nodes are your game’s smallest building blocks, arranged into trees. That is the whole idea of this lab: small parts, arranged, each with one job.
Frame time and speed
At 60 frames per second, each frame lasts 1 ÷ 60 = 16.67 milliseconds, so delta is about 0.0167 s. Movement per frame is speed × delta.
| Frame rate | Delta (s) | Pixels per frame at speed 200 | Pixels in one second |
|---|---|---|---|
| 30 | 0.0333 | 6.67 | 200 |
| 60 | 0.0167 | 3.33 | 200 |
| 144 | 0.00694 | 1.39 | 200 |
Without * delta the sprite would move 200 pixels every frame: 6,000 pixels per second at 30 fps, 12,000 at 60 fps, and 28,800 at 144 fps. It would also run 4.8 times faster on a 144 fps machine than on a 30 fps one.
Hand-trace (no computer needed)
Start with the sprite at (100, 100), speed 200, the right arrow held, 60 fps. Each frame: new x = old x + 1 × 200 × (1 ÷ 60).
| Frame | x | y |
|---|---|---|
| 0 | 100.00 | 100 |
| 1 | 103.33 | 100 |
| 2 | 106.67 | 100 |
| 3 | 110.00 | 100 |
| 4 | 113.33 | 100 |
| 5 | 116.67 | 100 |
| 60 | 300.00 | 100 |
Now hold up-arrow instead: get_vector returns (0, −1), so y falls by 3.33 each frame: 96.67, 93.33, 90.00. Up is negative y. Hold right and up together and the vector is normalized to length 1, about (0.707, −0.707), so diagonal movement is not faster.
A five-line build log (example)
- Created Sprite2D with the Godot icon; script attached; speed 200.
- Typed the movement lines; got a “mixed tabs and spaces” error.
- Retyped the indented lines with tabs; the error cleared.
- Tested: 60 frames of held right moved the sprite 200 pixels (measured on the debug overlay).
- Removed
* deltaas a test; the sprite left the screen in under a second. Restored it.
Each line says what you did, what broke, and the evidence it worked. This log is SLS original.
Sources: Godot documentation, Nodes and scenes (docs.godotengine.org); Godot FAQ (documentation license) (docs.godotengine.org)