The Interrupted Turn Keeper

Grade 2 Scratch 3.0 Simulation first Fair Play That Never Forgets
Simulation lab
Tool: Scratch 3.0
Open Scratch ↗
Simulator preview

Follow instruction sequences to guide the character to the goal.

📁 Tools ▴
  • Web browser (Chrome, Edge, Firefox)
  • Internet connection
  • Scratch 3.0 online editor

🔧 Build Your Interrupted Turn Keeper

1 Create two variables: 'current_player' (set to 1) and 'game_paused' (set to 0).
2 Program the Space key to alternate turns smoothly between Player 1 and Player 2.
3 Create a Pause trigger (P key) that freezes turn switching when assembly or recess interrupts play.
4 Add visual feedback so the active player's name and color shine clearly on screen.
🧩 Block plan / Starter code ▴
when [green flag] clicked
set [current_player v] to [1]
set [game_paused v] to [0]
say [Game ready! Player 1 goes first.]

when [space v] key pressed
if <(game_paused) = [0]> then
    if <(current_player) = [1]> then
        set [current_player v] to [2]
    else
        set [current_player v] to [1]
    end
    say (join [Active Turn: Player ] (current_player))
end

when [p v] key pressed
if <(game_paused) = [0]> then
    set [game_paused v] to [1]
    say [Paused! Turn saved safely.]
else
    set [game_paused v] to [0]
    say (join [Resumed! Ready for Player ] (current_player))
end

The game_paused guard prevents the turn counter from changing during an interruption.

⚗️ Test your model

Test Condition / ActionExpected Result
Press Space keyToggles turn display between Player 1 and Player 2
Press P key (Pause)Freezes turn keeper; says 'Paused! Turn saved safely'
Press Space while pausedTurn does not advance; previous active player is preserved
⚑ Try a challenge

Add a third player (Player 3 - Chidi) so three friends can share game turns fairly!

❓ Quick check
What does our 'active_turn' variable store inside the computer's memory?

📖 Our Story & Concepts

Have you ever played a fun board game with a friend during school break, and suddenly the bell rang for assembly? When you return to the classroom, who had the next turn? Arguments often happen when people forget!

Computers have a wonderful superpower called digital memory. By storing information in a labeled container called a variable, a program can remember who was playing even if hours pass or the game is paused. This ensures fairness and trust for everyone.

</> Full Annotated Code Walkthrough

// Full Turn Keeper with 3-Player Support & Pause Memory
when [green flag] clicked
set [current_player v] to [1]
set [game_paused v] to [0]
set [total_turns v] to [0]
say [Fair Play Turn Keeper Online!] for (2) seconds

when [space v] key pressed
if <(game_paused) = [0]> then
    change [total_turns v] by (1)
    if <(current_player) = [1]> then
        set [current_player v] to [2]
    else
        set [current_player v] to [1]
    end
    play sound [Pop v]
    say (join [Turn ] (join (total_turns) (join [: Player ] (current_player))))
end

when [p v] key pressed
set [game_paused v] to ((1) - (game_paused)) // Toggle 0 and 1

The game_paused guard prevents the turn counter from changing during an interruption.

▷ Expected Results & Troubleshooting

Test Condition / ActionExpected Result
Press Space keyToggles turn display between Player 1 and Player 2
Press P key (Pause)Freezes turn keeper; says 'Paused! Turn saved safely'
Press Space while pausedTurn does not advance; previous active player is preserved

⚑ Extension Challenges & Blueprints

⚑ Extension Challenges
  • Level 1: Add a sound effect that plays a high note for Player 1 and a low note for Player 2.
  • Level 2: Display a turn counter showing how many total turns have been played today.
  • Level 3: Add Player 3 so the rotation follows: 1 -> 2 -> 3 -> 1.

❓ Check Your Understanding

Question 1: What does our 'active_turn' variable store inside the computer's memory?

Question 2: Babatunde had to leave the game for 5 minutes. Why should we press 'Pause' instead of the Green Flag?

Question 3: If Player 1 finishes their turn, what math block changes the active turn to Player 2?

Question 4: What kind of block checks whether the game is currently paused before allowing a player to take a turn?

Feedback appears after you check your answer.