In Session 36, you made a sprite walk, speak, and turn once. But real computer programs don't just execute 3 blocks and stop dead. They keep running in a continuous cycle, make decisions when obstacles appear, and keep score. Today, you become a genuine game developer!
Think about preparing Fufu: one person pounds the pestle into the wooden mortar, and the second person turns the cassava. Pound, turn. Pound, turn. Pound, turn.
You do not hire 50 different people to strike the mortar once each! One person repeats the exact same action rhythmically until the fufu is smooth. In computer science, an automatic repeating cycle is called a Loop (or Iteration).
move 1 step blocks and stack them until your screen is cluttered and laggy.
repeat 100 block and drop a single move 1 step inside it. You just saved 99 blocks of effort!
In life, you make decisions based on real-world conditions every day:
• "IF it rains at 2:00 PM, THEN open my umbrella."
• "IF my stomach rumbles, THEN buy roasted plantain."
A Condition is a true/false question. If the answer is YES (True), the computer runs the special code tucked inside the block. If the answer is NO (False), the computer ignores it completely!
| Sensing Block | What It Checks For | Game Example |
|---|---|---|
<touching [mouse-pointer]?> |
Did the player hover over the sprite? | Button changes color when hovered. |
<touching [edge]?> |
Did the character hit the wall of the stage? | Bounces back or resets position. |
<key [space] pressed?> |
Is the player tapping the spacebar right now? | Character jumps over a puddle! |
Think about a traditional clay pot or wooden calabash kept in a village kitchen. You can put 5 cowrie shells inside it. If you earn 2 more, you drop them in and it now holds 7. If you spend 3, you pull them out and it holds 4.
In computer programming, a Variable is a named digital container that holds a value that can change (vary) while the game is running!
Starts at 0. Increases by +1 or +10 each time the player achieves a goal or collects an item.
Starts at 60 seconds. Decreases by -1 every second until it reaches 0 (Game Over!).
In 1947, computer pioneer Grace Hopper was working on a massive room-sized computer when it suddenly malfunctioned. When her team opened the machine, they found a real moth trapped inside one of the electrical relays! They taped the moth into the logbook with the note: "First actual case of bug being found."
Today, any mistake, logic flaw, or unexpected behavior in code is called a Bug. The detective process of finding and fixing that mistake is called Debugging.
Follow these 6 steps in Scratch to build a functional educational game teaching community sanitation:
Score → OK.
when green flag clicked into the workspace.
set [Score v] to (0) underneath it so points reset every new game.
forever loop under your reset block.
move (10) steps → then if on edge, bounce. Your sachet now patrols back and forth!
forever loop (below the bounce block), drop an if <> then block.
<touching [mouse-pointer]?> into the diamond hole.
if block, snap:
change [Score v] by (1)
go to [random position v] (from Motion: the sachet jumps away, so one touch = one point)
say [Cleaned!] for (0.5) secs
Cleanup_Game_Ama.sb3.
Read the code snippet below carefully and predict what happens:
What is the final number inside [Score] after the loop finishes?
Kwesi built a game where the player gets points by clicking a balloon. But when he clicks the green flag to start a second game, his Score starts at 45 instead of 0!
What block did Kwesi forget to put at the top of his script?
Tick the column that reflects your confidence at the end of the Programming Module:
| Programming & Logic Competency | With Help | Almost Alone | All By Myself! |
|---|---|---|---|
| 1. I can explain the difference between a `repeat` loop and a `forever` loop. | |||
| 2. I can use an `if-then` condition with a diamond sensing block. | |||
| 3. I can create a Variable (Score) and update it dynamically in code. | |||
| 4. I know the 3-step debugging protocol to trace and fix errors calmly. |
BIH JHS Tech Club ยท a Bozoma Innovation Hub programme ยท Your answers are saved only on this computer.