Getting Started with Raspberry Pi

Page 80

Finally, you can add sound effects to a sprite in the Sounds tab. Just hit record and you’ll get the built-in Sound Recorder tool. You’ll need an external USB sound card or microphone to be able to record sound. Give the sound effect a name and you can play it back using the play sound or play sound until done blocks.

A Bigger Example: Astral Trespassers In the game Astral Trespassers, the player must shoot at incoming alien spaceships; the game is over when an alien hits the player’s planet defending cannon. This simple game will show how all the pieces fit together. First select File→New, then save the new game by selecting File→Save As. Next you’ll need to create some sprites. Control-click or right click on the cat in the Sprite list and select Delete from the menu. Then create new sprites by painting your own or loading from an image file. I drew the 5 sprites in Figure 5-4 and scanned them in as a PNG. You’ll see that the sprites are added to the stage as you create them, and they are probably not the size you want them to be. Select the Grow Sprite or Shrink Sprite tool just above the Stage and click on the sprite to make it larger or smaller. You’ll also want to rename the sprites to use the names shown in Figure 5-4.

Figure 5-4. The 5 sprites for Astral Trespassers. The aliens and the cannon each have two states; normal and exploded. We’ll handle this by creating a costume for each state, as shown in Figure 5-5.

64

Getting Started with Raspberry Pi


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.