← Game Coding
Game Coding U1-L6 Your First Game Window

If and Else: Red Past 100

Right now your clicker will happily count to a million and below zero without blinking. Here's how a game learns to make a decision.

Teacher Notes

Not started yet.

Lesson Goal

Students will use if and else with a comparison to make the minus button stop at zero, and to make the label turn red when the count goes above 100 and white again when it doesn't.

Key Concepts

An if statement asks a yes-or-no question, which is called a condition. The braces right after it run only when the answer is yes, and the braces after else run when the answer is no.

The comparison marks are greater than, less than, greater than or equal to, less than or equal to, and two equals signs for is it the same.

A single equals sign puts a value into a box, while two equals signs ask whether two things are equal. Mixing them up is the most common mistake in this lesson.

Where Students Get Stuck

Using one equals sign inside an if when they mean to compare. Godot shows an error because the line is putting a value in a box and not asking a question.

Leaving out else, so the label turns red and stays red even after Reset. The else part is what turns it back.

Expecting 100 to turn red. The mark is greater than, so only a number strictly above 100 does, and the label stays white at 100.

Checking the Work

When this lesson is done, pressing F5 and clicking minus at zero should leave the number at 0. Clicking plus past 100 should turn the number red, and clicking Reset should turn it white again.

The label should be white at 100 and red at 101.

A parent can open Main.cs and compare the minus method and the UpdateLabel method to the code in the Watch It Worked. If a student changed the starting count to test, check that it was set back to 0.

Suggested Videos

Optional. Watch one first, then press Add to put it in the Visual Panel for a student.

Key Vocabulary

If
A tool that asks a yes-or-no question and runs its braces only when the answer is yes.
Else
The second door of an if, which runs when the answer was no.
Condition
The yes-or-no question inside an if, which must be plainly true or false.
Comparison
Putting two things side by side to check how they relate, such as greater than or equal to.
Sentence 1 of 26 Tap any sentence to start reading there
Settings

Settings

Stored on this device only. Your key stays in this browser. It is never sent to NexStudents, never shared, and never leaves your machine except to the voice provider it belongs to.

Where to get a key. Google Cloud TTS powers the built-in voices on this page and has a free monthly allowance. ElevenLabs is worth a look if you want a more natural voice and do not mind setting up an account.

Colors

Read-aloud is not available in this browser. Try Chrome or Safari.

Before You Start

The Words

The words this lesson uses. Tap a card to see what it means, then come back to them whenever a question uses one.

Part One

The Questions

0 of 0

Questions about the story you just read. Pick your answer straight off, or press Find it in the story if you would rather hunt for the sentence first.

Part Two

Vocabulary Check

0 of 0

The word cards are at the top of this page. Look back at them as often as you need, then answer.

When you finish: write the answers out in your own words — not copied word for word from the choices. Saying it your own way is the part that proves you understood it. Then use Print Answer Sheet for a one-page record of what was answered and scored.
Homework Sheet: UnavailableThere is no homework sheet for this lesson yet.