Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more.

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

3. Make Walking Blocks

Transcript

In this video, you'll program the sprite to walk between the projects by creating two walking blocks.

The walking block is a procedure.

Procedures are reusable code stacks that help simplify complex code.

First, we'll make the cat start off on the left side of the stage and walk to the center.

To do this, select the motion menu.

Use a go to block to set a starting position for the sprite.

The values in the go to block represent a position on the stage.

When you move the sprite, the values in the sprite update based on where the sprite is on the stage.

You can then pull the block out and the sprite will return to that starting position whenever it runs.

To make the sprite look like it's walking use a next costume block.

Click looks, and click the next costume block a few times.

Notice that the sprite looks like it's walking.

Pull this block out and put a repeat 10 block around it.

Try it again. Great.

The sprite goes to the starting position and starts walking but it doesn't go anywhere.

Program the sprite to move in a loop as well.

Click motion, and drag a move 10 steps block into the loop.

Right again.

Tinker with the values in the repeat block and the move 10 steps block until the sprite ends exactly where you'd like it to.

Okay, great.

You've know programed a way for the sprite to walk onto the stage.

Next, turn this code into it's own block or procedure.

Select make a block.

Here you get to name the block.

So choose something that makes sense, like walk on stage.

Then click okay.

A define block appears in the editor and a block appears in the pallet.

Add the define block to the top of your code that makes the sprite walk.

Then click the walk on stage block to try it out.

Great, the walk on stage block now works.

Drag it to the start of each event, so the first thing the sprite does when the backdrop changes is walk onto the stage.

Click the flag to try it out.

You should see the sprite walk onto the stage when the backdrop changes.

Next, make a block to make the sprite walk off the stage.

This will use much of the same code but you won't set a starting position.

Click make a block.

Call this block something like walk off stage and select okay.

Again, this procedure will repeat changing costumes and moving 10 steps 10 or so times.

Click the walk off stage block to try it out.

Great. Add this new block to the end of each block stack.

And click the flag to try it out.

When the flag is clicked, the first backdrop is displayed then the sprite walks on stage, says something and walks off stage.

When the backdrop changes, a similar process happens again.

Now that you have a working time-lapse project, complete with blocks that you've created, take some time to personalize it.

Make this project represent who you are, what you've done, and what you've learned in this club.

For some ideas on how to do this, check out the add-ons on the next page.

Now it's your turn.

Set a starting position for the sprite using a go to block.

Program the sprite to walk using repeat, next costume, and move blocks.

Define a walk on stage block and call it after each backdrop change.

Define a walk off stage block and call it at the end of each block stack.

arrow_backward Back
Next arrow_forward
Instructions
  1. Set a starting and gliding position for the sprite.
  2. Make the sprite look like its walking.
  3. Create a procedure for walking on and off stage.