SCRATCH GOLD II
SCRATCH GOLD I
2 of 3

5.05 Space-hippos

Now you’re going to add lots of flying hippos that try to destroy your spaceship.

Create a new sprite with the ‘Hippo1’ image in the Scratch library. Use the shrink tool to make the Hippo sprite a similar size to the Spaceship sprite.

screenshot

Set the Hippo sprite’s rotation style to left-right.

You can set which way a sprite rotates.

  • Click on the sprite in the Sprites panel.
sprite highlighted
  • Click on the direction and select the rotation style you want.
Different rotation style

The styles are:

  • All around — points the sprite in the direction it is facing
  • Left/Right — flips the sprite left or right only
  • Do not rotate — the sprite looks the same regardless of which direction it is facing

Add some code to hide the Hippo sprite when the game starts.

hippo sprite

Add some code to the Stage to create a new Hippo clone every few seconds.

Each new hippo clone should appear at a random x position, and every clone should have a random speed.

Create a new variable called speed that is for the Hippo sprite only.

  • Click on Variables in the Code tab, then click on Make a Variable.Variable blocks
  • Type in the name of your variable. You can choose whether you would like your variable to be available to all sprites, or to only this sprite. Press OK.Create variable
  • Once you have created the variable, it will be displayed on the Stage, or you can untick the variable in the Scripts tab to hide it.Variable on the stage

When you’ve done this correctly, the variable has the name of the sprite next to it, like this:

screenshot

When each Hippo clone starts, pick a random speed and starting place for it. Then show the clone on the screen.

Test your code. Does a new hippo appear every few seconds?

At the moment the hippos don’t move.

Each hippo should move around randomly until it gets hit by a lightning bolt. To make that happen, attach this code below the blocks that are already in the Hippo sprite’s code script:

Test your code again. You should see a new hippo clone appear every few seconds, and each clone should move at a different speed.

Now test the spaceship’s laser cannon. If a lightning bolt hits a hippo, does the hippo vanish?

×
×

Cart