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.

Choisir une extension
L'heure de faire la fête !
Crée une célébration de victoire de folie en utilisant certaines de ces idées.
Plates-formes en mouvement
Rends ton jeu plus difficile en créant des plates-formes qui bougent.
Plates-formes qui rétrécissent
Crée une plate-forme qui rétrécit pour augmenter la difficulté de ton jeu.
Plouf ! Tu as perdu
Crée une condition pour que le joueur perde à ton jeu.
Ajoute de la musique
Ajoute un fond sonore à ton jeu.
Résolution du bug : Atterris sur tes pieds... ou pas
Corrige le bug qui permet à d'autres choses que les pieds d'un lutin de rester sur une plate-forme.
arrow_backward Retour
Suivant arrow_forward
Instructions
  1. Choisis une extension, et clique sur "Regarder" pour découvrir comment personnaliser ton projet.
  2. Quand tu as fini, reviens à la page des extensions et essaies-en une autre !