Project B: a game with points and chance
Be able to build a game with chance, points and a winning condition, and explain how it works.
Prerequisites
Everyday explanation
The project: a game that is different every time (chance), counts points (variable) and can be won (condition).
Example: Catch the stars. Stars appear in random places. You steer a character. Every star gives a point. At 10 points: «You won!». A ghost moves at random — if it touches you, you lose a life.
Requirements: at least one random instruction, at least one variable, a winning condition and a losing condition.
Interactive
Plan before you build — write it in a table:
| Sprite | What does it do? | Variables |
|---|---|---|
| Player | steered with the arrow keys | lives = 3 |
| Star | random place, disappears when hit | — |
| Ghost | moves at random | — |
| The game | if score = 10: win; if lives = 0: loss | score = 0 |
Build one sprite at a time and test it. A common bug: the score goes up many times for one hit — add a wait, or move the star immediately.
Mastery means
- Builds a game with chance, points and a winning condition
- Explains how chance, variable and condition work together
- Tests the game and fixes at least one bug
Sign in to do the exercises and build your mastery up.
Sources
- Scratch Wiki (CC BY-SA 4.0) — CC BY-SA 4.0
- CS Unplugged (CC BY-SA 4.0) — CC BY-SA 4.0