{% trans 'Watch it here now.' as msg_meta_extra} Drift - Window Shopper - CS First Skip to content

Please update your browser

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

Transcript

This add on will create a sprite that will perform different actions in response to its surroundings.

To start click on, choose new sprite from library, and add a new sprite.

This project we'll use the beach ball for the summer sale blowout, but you can pick any sprite you'd like.

Make your sprite smaller to fit on your stage.

Next, make the beach ball bounce randomly around the screen.

To do that use a glide block from the Motion menu to make the sprite move.

Then place pick random blocks in the x and y values of the glide block to make the sprite go random places on the screen.

The values in the pick random blocks create a range of coordinates for the sprite to move to.

The computer will choose a random value between these two numbers and the sprite will move to that spot on the screen.

The width of the stage is negative 240 to positive 240 so add those values into the pick random block for x.

The height of the stage is negative 180 to positive 180 so add those values into the pick random block for y.

You can also add a pick random block for the seconds it takes to glide to different points on the screen, so the sprite moves for a random amount of time.

Do what looks best in your project.

Try your code by clicking on the block stack.

To make this continuously happen, place a forever loop around the glide block and add a when flag clicked block on top of this block stack.

Test it out.

Cool, you can also make the beach ball do different actions when it touches other things on the stage.

This example we'll code for if the beach ball touches the hippo and if the beach ball touches the sides of the window display.

Drag out two if then statements from the Control menu.

Add two touching blocks from the Sensing menu into the if then statements.

In this example, one is touching hippo, and the other is touching window display.

You can make the sprite do whatever you want when it touches another sprite or the window display.

For this example when the beach ball touches the hippo it will turn right 60 degrees.

When the beach ball touches the window display sprite, it will turn left and change its color effect.

Add these blocks inside the first if then statement.

Add a when flag clicked event at the top of this block stack to test your program.

Nothing happens.

The sprite should check the conditional statements continuously so place a forever loop around both if then statements.

Now test the code.

Awesome, when the beach ball touches the hippo it spins and when it touches the store front the beach ball turns and changes color.

Now when shoppers walk by they can see the beach ball in action.

Now it's your turn.

Add a new sprite, code it to move randomly across the screen using glide, pick random and forever blocks.

Add conditionals to your sprite so that it will do an effect when it touches the window display, another sprite or the mouse pointer.

You can add any blocks you like inside your if then statements.

Don't forget to add when flag clicked events to run your code when the flag is clicked.

If you have a question ask your neighbor or, put up your sticky note to get the attention of your CS First guru.

Choose an Add-On
Color Change
Create a sprite that changes colors when the mouse hovers over it.
Drift
Create a sprite that will perform different actions in response to its surroundings.
Hidden Surprise
Code a hidden surprise in your display window.
Go Crazy
Code your sprite to go crazy when the mouse-pointer touches it.
Talk about it (Challenge)
Add talking sprites in your program.
Shooting Sprites (Challenge)
Make a sprite shoot across the stage.
arrow_backward Back
Next arrow_forward
Instructions
  1. Choose an Add-On, and click "watch" to learn how to build it.
  2. Once you finish one Add-On, try another one below the video!
Attributions
  • "Grand Opening' by csf11191 (https://scratch.mit.edu/projects/44999602/) -- Licensed by CC BY-SA 2.0 (https://creativecommons.org/licenses/by-sa/2.0/)
  • "Window Shopper Starter Project remix" by csf18500 (https://scratch.mit.edu/projects/40063188/) -- Licensed by CC BY-SA 2.0 (https://creativecommons.org/licenses/by-sa/2.0/)
  • "Window Shopper Starter Project remix" by csf3400 (https://scratch.mit.edu/projects/43007680/#editor) -- Licensed by CC BY-SA 2.0 (https://creativecommons.org/licenses/by-sa/2.0/)
  • "Window Shopper Starter Project remix" by csf21653 (https://scratch.mit.edu/projects/50079138/) -- Licensed by CC BY-SA 2.0 (https://creativecommons.org/licenses/by-sa/2.0/)