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.
Not started yet.
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.
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.
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.
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.
Optional. Watch one first, then press Add to put it in the Visual Panel for a student.
Read-aloud is not available in this browser. Try Chrome or Safari.
Before You Start
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
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
The word cards are at the top of this page. Look back at them as often as you need, then answer.