In this exercise we'll use the Open Roberta editor. Make sure that you see this picture in the upper right corner of your programming environment. The editor can be found on our website at the top of the navigation bar: Let's start - Editor.
First steps: Fortune telling ball
Dein Calliope mini kennt die Antwort.
First, you create a variable. Click on the + symbol in the Start block. Then name the variable with random.
To display a question mark at the start of the minis, take the show text block you find under action, change text to character and enter a question mark.
Select the following block in the menu under control to play your following code in an endless loop.
Now select the if - do block under control to set the condition. Then add the get shaking gesture from the sensors menu to control the position sensor. In the selection change upright to shaken.
Next, select the set random block from the variables menu. To these you add the integer random value between 1 and 100 block, from the math menu, change the 1 to a 0** and the 100 to a 3.
Now the value of the variable random is randomly set to a number from zero to three.
Now add another if - do block and add the block = from the logic menu to it. Now you fill the block with the random variable, from the variables menu and a 0 to set the condition for the value zero of the variable. Then take a show text block and enter your answer in the text box.
You can duplicate this if - do block four times. To do this, right-click on the if - do block and choose copy. For the further random numbers 1-3 of your duplicated blocks you can now define the statements. In each of the three blocks, make the following statements:
- change the random number
- enter your text
- put your blocks together
So that you have a little time to display the next answer, you can include a pause. For this you take the wait ms block, which you can find under control. Try different waiting times until you like a period.
To display a question mark after the answer again, add a show text block at the end. Now all you have to do is change text to characters and enter the question mark in the text field.
Done - download your script and try it out!