Wednesday, December 21, 2011

Game show scoring

In the previous Malibu Beach Crab project we saw how to keep score in Scratch using a variable. Here we will create a more interesting and entertaining way to sum up scores. Have you ever played a game or seen a gameshow where, by the end of a section you would see the scores total up with the numbers moving, sometimes with sound effects? We will see exactly how to do this.

I have put this Scratch tutorial in a project itself, so you can simply watch it. Feel free to download the script template for score keeping (or as I call it, gameshow scoring) and reuse in your own projects!

If you prefer reading the tutorial, then continue on…

Tutorial: Game show scores on Scratch

We do this in only two steps:

1. Prepare variables

Obviously, we need at least one variable for the scores, and an additional one to keep the total. In this tutorial, we will create three variables for the scores (i.e. score1, score2, score3) and another (i.e. totalScore) for the total score. In my tutorial project above, I populate score1, score2 and score3 with random numbers for illustration purposes. Normally, we would use them to keep more meaning scores. You may look at the the Fruit Basket project to see how I use them to keep count on different fruits.

2. Do the scoring

The main idea here is that we want to sum up score1, score2 and score3, and put the sum in totalScore. We could have just gone and set totalScore with the sums like this:

Summing up scores (in a boring way)
This is quick and silent. We won't do this because we want something dramatic! What we want is to see score1, score2 and score3 decreasing one by one as totalScore sums them up. We also want to add sound effects to make us feel good about the many points we have scored! So this is what we do instead:

Summing up score1 (in a more interesting way)
We repeatedly decrease score1 until it is zero. Every time we decrease it, we increase totalScore. Here I increase it by just one, but it could be any number (in Fruit Basket I increase totalScore by different amounts depending on which fruit it is). As we do this, we also play a note for a very short beat. Which instrument and note, and how many beats it should play are of course up to you to vary to your liking.

Wait 0.5 seconds before appending similar blocks to sum up score2
After score1 is done, we wait a while before moving on to score2. We do the same for score3 by appending similar blocks below the ones for score2. If you have more scores to sum, then just add more repeat until blocks to the template with the variables adjusted accordingly.

Appending similar blocks below to sum up score3

1 comment: