Please note: This theme has not been updated to reflect Scratch 3.0. Visit this help article for more info.
Transcript

In this add-on, you'll program a power-up to enable the hero to jump higher and stay in the air longer.

A power-up will act a lot like a bug.

It will appear randomly and slide across the screen.

Then, it'll make something happen when it touches the hero.

Since they're similar, start by copying the bug sprite.

Right-click the Bug sprite in the sprites menu.

Then, click duplicate.

Rename the power-up sprite.

Your enemies and your power-up shouldn't look the same, so click the costumes tab and add a new costume to make the power-up look different.

Pick either choose costume from library or paint new costume.

Next, delete the old bug costume.

You may not have seen this code before, so take some time to understand everything that's happening because you'll have to tweak it later.

The first block stack puts the original sprite in the right place and hides it.

Then, the loop at the end makes the clones at random times.

What you see in the game are the clones.

You can see, in the next stack, where the clones show then move across the stage.

Tinker with the times in the pick random block.

In the glide block, consider making the wait time longer, so the power-up is rarer.

Click the Hero sprite to make the code that will power your hero up.

The value that controls how hight the sprite jumps is in the set y speed block.

To make it jump higher, make this value bigger.

Make another variable that will change when you get the power-up.

Call the new variable jump speed.

Then, drag it into the set up down speed block.

At the top of the block stack, above the motion loop, set jump speed to 15, just like the number it replaced.

Great!

Drag out two more set variable blocks and set jump speed in both.

In the first one, type a value bigger than the original.

Tinker around with this.

The example uses 20.

If you click the flag, then click on this block in the up arrow, the hero will jump to heroic heights every time, but its energy should wear out eventually.

Snap a weight block and the other set variable block below the first set variable block.

In the second set variable block, type the original value, 15 in this example.

Tinker with the weight value to change the amount of time the hero keeps the special power.

Add a new if block and snap it somewhere just inside the motion loop.

It may want to nest further inside or wrap around the other code, but don't let it do that.

When you get it positioned, you should see an empty if block.

The condition is a touching block.

Select the power-up sprite.

Then, if it's touching, broadcast the message to make the power-up happen.

Snap in a broadcast block, make a new message, then top up your new power-up stack with a when I receive block.

Select the message you just created.

Select the message you just created.

Test.

Click the flag and wait until the power-up comes along.

If it works, great!

Go back and tinker with all the values until you get the power-up working the way you like.

Now it's your turn.

Duplicate the bug and change its appearance to make it look like a power-up.

Add a jump speed variable.

Set and change the variable at appropriate times.

Make the sprite increase its ability when it touches the power-up using the broadcast and if blocks.

Choose an Add-On

Game Over

Give your hero a set number of lives.

Laser

Program your hero to shoot lasers to vanquish the evil bugs.

Power-up

Add a power pellet to make the hero jump higher.

Falling Rocks

Add a falling obstacle to your game.

Platforms

The terrain of your game will change to move up and down.

Follower Friend

Add a cute buddy who follows your hero around.

Instructions

  1. Choose an add-on, and click "watch" to learn how to customize your project.
  2. When you finish, come back to the add-ons screen and try another add-on!