Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more

4. Eine Gewinnbedingung programmieren


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 do something more complicated, like play a “ya” sound and make the player sprite glow.

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 for some inspiration.

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: 1) Program a winning condition or celebration using “touching” and “if” blocks.

arrow_backward Zurück
Weiter arrow_forward
  1. Verwendet einen Block „falls“, um zu prüfen, ob der Nutzer das Spiel gewonnen hat.
  2. Programmiert eine Siegesfeier!