Mr Laliberte

GDScript Basics

Game Development with Godot · Variables and Data · Lesson 1

Courses › Game Development with Godot › GDScript Basics

Your First Steps in Game Programming — Follow-Along Handout

What You’ll Be Able to Do By the End of Today

  • Open Godot and find your way around the main window

  • Explain what a variable is, in your own words

  • Attach a script to something and open the script editor

  • Type a simple line of code without errors

  • Run your project and find your own output on screen

Key Words for Today

Keep this page open — we’ll use these words a lot.

Word Plain-English Meaning
Script A list of instructions for the computer
Line One instruction, on its own row
Indented Pushed in with a tab/spaces — shows it belongs to the line above
Run Tell the computer to follow the instructions
Output Where the computer shows us what happened
Variable A labeled box that holds a piece of information

Part 1 — Finding Your Way Around Godot

We are going to create a new project together. As I point to each part of the screen, find it on your own screen and check it off:

  • The big middle area — this is your game world

  • The panel on the left (“Scene panel”) — lists everything in your game

  • The panel at the bottom (“Output panel”) — where the computer talks back to you

  • The Play button (▶ triangle, top right) — runs your game. Don’t click it yet!

Part 2 — Attaching a Script

A script is just a list of instructions for something in your game. Follow these steps as I do them:

  1. In the Scene panel (left side), click once on the item listed there. It should highlight.

  2. Look at the small toolbar of icons just above that panel. Find the icon that looks like a scroll or a page.

  3. Click it. A window titled “Attach Node Script” will pop up.

  4. Leave everything as it is — just click Create.

  5. A new area opens at the top of your screen. This is the script editor!

Part 3 — Reading Your First Script

Godot fills in some starter text automatically. Here’s what it means:

extends Node2D

func _ready():
    pass

func _process(delta):
    pass

_ready() → everything indented underneath happens ONE TIME, the moment the game starts.

_process(delta) → everything indented underneath happens OVER AND OVER, many times per second. (We’ll use this in later classes.)

pass → a placeholder meaning “nothing happens here yet.” We replace it with real code when ready.

Part 4 — Two Rules of Code Grammar

Part 5 — Your First Variable

Delete the word “pass” under _ready(): and type this one line at a time:

func _ready():
    var health = 100
    print(health)

var → the magic word that means “I’m creating a new labeled box.”

health → the label on the box. You can name it almost anything.

= 100 → puts the number 100 inside the box.

print(health) → shows what’s inside the health box, in the Output panel.

Part 6 — Running It!

  1. Click the ▶ Play button.

  2. If Godot asks to save the scene, click Save.

  3. Look at the Output panel at the bottom of your screen.

  4. You should see the number 100 appear. That’s your first working program!

  5. Which line of code produced that number? Write your answer below:

Part 7 — On Your Own: Hands-On Practice

In a new project, create these three variables inside _ready(), and print each one:

func _ready():
    var my_name = "___"        # put your own name in the quotes
    var favorite_number = 7    # change this to any whole number
    var health = 100

    print(my_name)
    print(favorite_number)
    print(health)

✅ Success looks like: three lines appear in the Output panel when you press Play.

Early finisher challenge: Add a fourth variable of your own choosing and print it too!

If Something Goes Wrong

  • Did you forget the colon : after _ready()?

  • Are your indents (spaces at the start of the line) consistent?

  • Did you put quotation marks around words/text, but NOT around numbers?

  • Did you save the scene before pressing Play?

Errors are normal! The Output panel will show a red message and even tell you which line to check.

Exit Ticket — Answer Before You Leave

  1. In your own words, what is a variable?

  2. Where do you look to see what your program printed?

  3. What’s one rule about how lines of code need to be formatted?

Great work today! Next class: different kinds of variables and simple math with numbers.

Welcome back