Skip to content

Please update your browser

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

2. Your Home Will Be...

Transcript

The Imaginator flashes different possibilities for your friends' future and chooses one when he or she presses the space bar.

This video will guide you through the steps.

Click on the sprite named Home.

From the Looks menu, drag out a Next Costume block.

Click on this block to see what it does.

The home sprite changes.

This is because the sprite has many costumes.

To see the different costumes, click on the Costumes tab.

Then, flip through them.

Awesome!

The program should repeat, cycling through different homes until your friend presses the space bar.

That's where the loop comes in.

A loop makes something in your project repeat over and over.

You can find loops in the control menu.

For today's project, the program should repeat showing the next costume until your friend presses the space bar.

So, drag out the Repeat Until block.

Place it around the block that should repeat.

In this case, Next Costume.

Click on the code.

The sprite cycles through lots of different homes quickly.

Next, tell the program when to stop running the loop.

Note the gap after the Repeat Until block.

This is where the condition that stops the loop goes, making the homes stop cycling when the space bar is pressed.

Select the Key Press condition from the Sensing menu and place it in the gap in the Repeat Until block.

From the drop down menu, select Space.

The homes keep changing but now they stop when the space bar is pressed.

Click on the code to test it.

From the Events menu, add a When Flag Clicked block so the code will run when your friend presses the green flag.

Test your code.

Awesome!

When the flag is clicked, the program runs.

Now it's your turn.

Change the home sprite's costume using the Next Costume block.

Make the costume keep changing with Repeat Until and Key Pressed blocks.

Add a When Flag Clicked block.

arrow_backward Back
Next arrow_forward
Instructions
  1. Change the home sprite's costume with the "next costume" block.
  2. Make the costume keep changing with "repeat until" and "key pressed" blocks.
  3. Add a "when flag clicked" block.