Skip to content

Please update your browser

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

3. Make Walking Blocks

  • 1. Time Lapse Introduction
  • 2. Describe Your Projects
  • 3. Make Walking Blocks
  • 4. Add-Ons
  • 5. Reflection
  • 6. Wrap-up: Time Lapse
  • 7. Wrap-up: Share Your Project
  • 8. Wrap-up: Show Your Project
arrow_backward Back Next arrow_forward
Transcript

In this video, you will 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, you will make the cat start 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 block 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 the loop as well.

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

Try it 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.

Ok great!

You’ve now programmed a way for the sprite to walk onto the stage.

Next, turn this code into its own block, or procedure.

Click “more blocks,” and select “make a block.”

Here, you get to name the block, so choose something that makes sense, like “Walk on stage.”

Then click ‘OK’.

A “define” block appears in the editor, and a block appears in the palette.

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 the more blocks menu and “Make a Block.”

Call this block something like, “Walk off stage,” and select “OK.”

Again, this procedure will repeat changing costumes and moving ten 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.

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.

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.