In this posting I want to talk about two things that are missing from the current version of Scratch (I'll also mention the upcoming version).
Before I start I want to acknowledge that the designers of Scratch were anxious to keep the environment simple so that newcomers and kids would not find it too confusing. So the omissions that I am highlighting here were no doubt conscious decisions by the designers. But for people who are used to other languages they are very surprising (and quite annoying to be honest).
The first is that there is no FOR loop.So if you want to perform a loop X times while changing a variable from 1 to X with each iteration, you have to do that yourself. So you need to set the initial value, check against the limit, and increment the variable by hand each time yourself.
In Whack-a-Bird I needed to a nested FOR look to move across the 3x3 matrix of holes while drawing them. Here is now the code ended up (this would have been a lot tighter if there were a FOR block):
In the new version of Scratch (2.0 - currently in beta) there is still no FOR loop!
The second omission is that you can only convert a floating point number to an integer using the ROUND block. There is no block for truncating or rounding down. This is a big omission for games writing.
For example, if you want to convert a number to two components to work with a 4x4 matrix, you will use division and the modulo function to get the two components. In Java it would look like this:
int y=number/4;
int x=number % 4; // % in Java is the remainder or modulus or modulo operator
Here is how that would look in Scratch. The second line will work as expected but unfortunately the ROUND block will change the answer by rounding up the result when you don't want it to:
The good news is that this HAS been addressed in Scratch 2.0 which, in addition to a ROUND function, has both CEILING and FLOOR functions.