4. Using If-Statements to Win


[Narrator] - In this video, you will program a winning condition for your game.

The user will win the game when the player sprite goes through the maze and catches the goal sprite without touching the boundaries.

The if, then statement you'll create will read something like this: If touching the goal sprite, then say, "You win!"

To start, drag an if, then block into the forever loop.

Next, add a conditional block.

Remember, it's easier to choose the right blocks to create a conditional statement, when you think or say what the program should do.

In this case, you might think or say, "The user will win if the player sprite touches the goal sprite."

To make that happen, use a touching block and change the value to goal sprite.

Now this reads, "If touching the goal sprite, then..."

The then part is up to you.

Tell the computer what to do if the player sprite is touching the goal sprite.

It could be something simple, like, "Say, 'You win!'" Or, it could be something more complicated, like, "Play a 'ya' sound and make the player sprite glow."

(ya sound)

Tinker with your code and find a solution that works for your program.

You might have finished programming this activity, but you can still add more to your project.

Check out these other CS First member projects and get inspired to add to your own.

As your last step today, share your project with the Scratch community so others can experience your creative work.

Don't forget to add a description and some tags.

Write instructions for how to use your project and show appreciation for anyone who helped you create it on the project page.

Now, it's your turn.

Program a winning condition or celebration using touching and if blocks.


  1. Use an "if" block to check if the user has won the game.
  2. Program a celebration!
  • "Day 3 Maze: Starter Project remix" by csf2862 -- Licensed under CC BY-SA 2.0 (
  • "Beetle Battle" by csf1168 ( -- Licensed under CC BY-SA 2.0 (
  • "Day 3 Maze: Starter Project remix" by csf4406 ( -- Licensed under CC BY-SA 2.0 (
  • "Besty and the Maze" by csf1477 ( -- Licensed under CC BY-SA 2.0 (