Mission 02 · Lesson 06
Give the game rules
Coding & Game Development
Work at your pace. Take a break between stages; there is no countdown.
You need: paper, a pencil and this lab. A helper is welcome for reading and discussion.Connect to what you know
Your button moves the player. Now add a rule that decides when a point is earned.
Understand it, step by step
- 1
A condition asks a question with a true or false answer. “Position equals target” is a condition.
- 2
IF that condition is true, add a point; ELSE keep the score. A point should not be awarded for every movement.
- 3
A boundary is where behaviour changes. Test just before the target, on it and just after it. These tests catch a rule that is too broad.
Watch a worked example
Target = 3. At position 2: false, score stays. At 3: true, earn a point. At 4: false. “Position at least 3” would wrongly award a point at 4 too.
Pause and predict
Which of the three positions should earn a point?