Saturday, March 26, 2011
Flash Player improvements
Thanks to everyone who reported bugs in the new flash-based Scratch project player! We’re now up to version 23 (the third version since the original release), and so far we’ve fixed over 20 confirmed glitches. Lots of Scratchers have posted detailed bug reports on the forums, which is really helpful. The more glitches we can find and fix now, the better we can make the flash player (and the next version of Scratch).
Create your own block
One of the new features we’re excited to add to Scratch is the ability to create your own blocks -- called “procedures” in the language of computer science. Creating your own blocks can be really handy. For example, let’s say you want to create an animation with a sprite that jumps in the air. Each time the sprite jumps, you need to tell it to go up, wait a little while, and then come back down again. That takes at least 3 blocks for every jump.
A simple “jump” script.
If you want to make your sprite jump, move, and then jump again, you might make something like this.
A “jump, move, jump” script.
In Scratch 2.0, you can do the same thing by creating your own jump block. You tell Scratch what your jump block does by creating a special script that defines the new block:
Creating a jump block to make a “jump, move, jump” script.
In this example, the jump block makes the sprite jump up, wait a half second, and then come down again. Each time Scratch comes to a jump block in a script (like the script on the left), Scratch runs the commands in the jump definition script (on the right). Combining the commands for jumping into a single block makes scripts easier to read.
In the next version of your project, you might want to be able to control how high your sprite jumps. Without the ability to make your own jump block, that could be a real pain. You’d have to find each and every “change y by 50” block that was used for jumping in your project, and change the 50 to something else. But with the new create-your-own-block feature, you can just add an input that tells the jump block how high you want it to jump.
Creating a jump block with a “height” input.
Now each time the jump block is run, the value of the height variable will be set to whatever number is entered as an input on the jump block. In this example, the first jump block has an input of 25, so the height variable will be set to 25 and the sprite will jump 25 pixels high. The second jump block has an input of 50, so the sprite will jump 50 pixels high.
We’re still in the process of figuring out the best way for Scratchers to create their own blocks, and there are still many questions. For example, if you create a jump block in one sprite, would other sprites be able to use the jump block too? Should the definition script appear in only one sprite -- and, if so, how would people find it? Should you be able to define “jump” differently in different sprites? These are few of the questions we have to think through before we’re ready to put this cool feature in the next version of Scratch.
Have ideas or thoughts about this? Post them in this thread in the Scratch forums.