
Banana Splat, Part 2
1. By now, you are probably arguing with your friends about who is better at chucking bananas at birds. The only way to solve this
is to keep score. Because we’re too lazy to do this with pencil and paper, we’ll have the computer do it. And to do that, we’ll need
variables.
2. Click on the Bird sprite and click on Data.
3. Click Make a Variable, name it Attempts, and click OK. Notice that the box next to the variable’s block is checked. This displays
the variables value on the screen, which is good, because we want to see your score.
4. Create two more variables, one named Hits and one named Percent.
5. Add set Attempts to 0, set Hits to 0, and set Percent to 0 to the script that is executed when the green flag is clicked.
6. In the script that is executed when the message “Fly” is received, add the following after the repeat until block:
A change Attempts by 1 block.
An if-then block that changes Hits by 1 if the bird is touching the banana.
A block that sets Percent to (Hits/Attempts)*100.
7. Save your project. Click the green flag and earn your bragging rights.
Commenti su questo manuale