Skip to content

Please update your browser

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

Transcript

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.

Scegli un’estensione
È tempo di festeggiare!
Crea una fantastica celebrazione utilizzando alcune di queste idee.
Piattaforme mobili
Rendi il tuo gioco più impegnativo creando piattaforme mobili.
Piattaforme che si riducono
Crea una piattaforma che si riduce per aumentare la difficoltà del tuo gioco.
Splash! Hai perso
Inventa il modo in cui il giocatore perderà il gioco.
Aggiungi dei brani
Aggiungi una musica di sottofondo al tuo gioco.
Risolvi il bug: Atterra sui piedi... oppure no
Risolvi il bug che permette a elementi diversi dai piedi di uno sprite di stare su una piattaforma.
arrow_backward Indietro
Avanti arrow_forward
Istruzioni
  1. Scegli un componente aggiuntivo e fai clic su "Guarda" per imparare come personalizzare il tuo progetto.
  2. Quando hai terminato, torna sulla schermata dei componenti aggiuntivi e prova un altro componente aggiuntivo!