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

This add-on uses a new concept, “repeat until,” and is more challenging than some of the others.

As the programmer, you will get to choose the password. First, you will need to ask for the password.

To do this, use the same block you used to ask if the character should go through the secret door, the “ask” block. Type a question in the “ask” block. This example says, “Apparently to go through the door I need a password. What is the password?”

This add-on is different from “should I go through the secret door?” in the core project. In this add-on, if the user doesn’t get the password right, the program will keep asking for a password. To keep doing something over and over, use a loop. The “repeat until” loop, for example, allows something to keep happening until a condition is met. From the control menu, drag out a “repeat until” loop. Place it below the “ask” block. Start by filling out the condition.

In the core project, the condition was “answer = yes.” The condition for this add-on is very similar: This example uses the password “scratch,” so the condition reads “answer = scratch.”

For this add-on, the program should keep asking for a password until the user enters the correct one. To ask for the password again, put the “ask” block inside the “repeat until” loop. Make the “ask” block say something that will help the user understand what happened. This example says “That wasn’t right.

What else could it be?”

If not, they'll will be stuck inside the loop forever! Make sure you give the user a chance to enter the correct password. Click on this code to test it. The character asks for the password. To make sure the “repeat until” loop works, first type an incorrect answer. This example enters “cat.”

Since the condition “answer = scratch” was not met, the code inside the repeat loop will execute. For this example, that code asks “That was not correct, what else could be?” Try one more incorrect test. This example types “dog.” The code inside the repeat loop should run again.

This time, answer correctly. In this example, the correct password "scratch" is entered.

So the repeat loop stops running and the story continues.

If you would like your story to wait to start until the correct password is entered, place the code you just created under the green flag. You could also instruct the program to ask for the password before the character goes through the secret door, or at another point in the story that makes sense to you. This example asks for the password when the user has already decided to go through the door, so it runs after the “then” portion of the “if answer = yes” block. Test your code by clicking on the green flag.

The program should only continue after you’ve entered the right password.

Finally, you can add a “say” block that lets the user know the password was correct.

Erweiterung auswählen
Die Figur gehen lassen
Die Figur sich auf die Tür zu oder von ihr wegbewegen lassen
Ein Passwort hinzufügen
Ein geheimes Passwort programmieren, das der Nutzer eingeben muss, um durch die Geheimtür gehen zu können
Regen programmieren
Das Lager in Scratch dazu nutzen, um den Regen aus dem Projekt von Aktivität 3 in dieses Projekt einzufügen
Die Geheimtür verstecken (Herausforderung)
Die Hauptfigur so programmieren, dass der Nutzer sie mit den Pfeiltasten steuern und bewegen kann, um die Geheimtür zu finden
Eine neue Figur hinzufügen (Herausforderung)
Weitere Figuren zu eurer Geschichte hinzufügen
Eine neue Szene hinzufügen (Herausforderung)
Eine neue Szene hinzufügen und ein paar Ideen für euer Projekt erhalten
arrow_backward Zurück
Weiter arrow_forward
Anweisungen
  1. Wählt eine der Erweiterungen aus und schaut euch das Video an, um zu sehen, wie sie programmiert wird.
  2. Wenn ihr mit einer Erweiterung fertig seid, probiert eine andere aus!