O'Reilly logo

Raspberry Pi For Dummies by Mike Cook, Sean McManus

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Naming Your Sprites

Whenever you’re programming, you should give things meaningful names so that you (and others) can easily understand what your program does. Scratch gives your sprites names like Sprite1 and Sprite2, but you can rename them. To rename a sprite, click its name above the Scripts Area (see Figure 11-3) and then type its new name. Your sprite’s costumes are called costume1, costume2, and so on. If you’ve created different costumes for your sprite, you should also give them sensible names so you can easily tell which is which. Go to your sprite’s Costumes tab, click the name beside a costume (see Figure 11-3), and type the new name.

For the space game, you need to create a flying saucer sprite named ship and a sprite named fireball to represent the ship’s weapon. The baddie is a sprite called alien, and should have two costumes: alienok, which shows him looking menacing, and alienhit, which shows him after he’s been hit by the fireball.

To make it easier to see what you’re doing, we recommend you drag your ship to the bottom of the screen, the alien to the top, and put the fireball somewhere in the middle. That roughly reflects where they will be in the finished game.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required