In this video, you will program a winning condition for your game. The user will winthe game when the player sprite goes through the maze and catches the goal sprite withouttouching the boundaries.
The if then statement you'll create will read something like this: "If touching the goalsprite, then say “you win!" To start, drag an “if/then” block intothe forever loop. Next add a conditional block. Remember, it’seasier to choose the right blocks to create a conditional statement when you think orsay 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 couldbe 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 experienceyour 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 helpedyou create it on the Project Page.
Now, it’s your turn: 1) Program a winning condition or celebrationusing “touching” and “if” blocks.