arrow_back Splash! You Lose
In many platform games, the main character can fall to their doom. Right now, this character falls off a platform, and the player can just try again. It’s time to give this game a “losing” condition. Watch this screencast to learn how to do that, then try on your own.
First, there needs to be a dangerous place to fall, like water or lava.
To do this, create a new sprite.
You could draw your “dangerous place” right on the game backdrop, but creating a new sprite makes it easier to position the danger element on the screen, edit, and program it.
In this example, the dangerous place will be a blue line like water, but you can draw any kind of “dangerous place” you want.
Now, something needs to happen IF the character touches this “dangerous place” sprite.
There are a few different ways to program this if statement, but because the winning condition is programmed for the player sprite, the losing condition should be, too.
Computer scientists often work together on programs, so it’s a good idea to organize your code in a way that makes sense and is easy for other people to find and work with.
Putting winning condition next to the losing condition seems like a good way to organize this code.
Click on control, and place an "if statement" below the winning condition inside your "forever" loop.
Go to sensing, and drag out a “touching” block.
Change the value to the name of the “danger sprite.” In this case: Sprite 1.
Now, inside the "if statement", put what should happen when the character loses.
It could be something like saying, “you lose” and stopping the rest of the program from running.