In this video,
you'll learn how to use the pick random block
to make your clone's movement unexpected and interesting.
Click on the Operators menu
and drag the pick random block into the value area
of the wait block.
The pick random block chooses a random number
between these two values each time it runs.
With the pick random block inside the wait block,
the computer might wait one second, then five seconds.
It'll choose a random wait period every time.
With the pick random block added,
the flying clones do not fly onto the screen
over and over at the same pace.
Remember, you can always experiment with these values.
Now that you've randomized how long the computer waits
between creating clones,
randomize where the clones start and glide.
Start the sprite at a random height
by adding another pick random block
to the go to block's y value.
Set the values to negative 180 and 180
to represent the top and bottom of the screen.
To make the sprite glide to a random height,
add another pick random block with the same values
to the glide block.
Test this out.
The clones should now start and end
at random heights.
You can further experiment with random values
by making the clones glide at different speeds.
Add a pick random block to the seconds value
in the glide block.
The size of the clone can also be randomly generated.
Click on the Looks menu,
drag out a set size to 100 block
and add it to the top of the
when I start as a clone stack.
100% is the original size.
A value smaller than 100% will make the clone smaller.
To randomly select a value for the size to block,
add a pick random block.
Choose the smallest and largest percent values
you want the clones to be.
Test your code.
Now, the window is filled with many clones
of the flying sprite.
And each clone has its own randomly selected size,
speed, and behavior.
By cloning these sprites, you've created many objects,
each with its own attributes, like size,
and its own behavior like gliding speed.
Lastly, place the storefront sprite
in front of your other sprites.
To do this, click on the storefront and the Looks menu.
Drag out a go to block,
and place a when flag clicked event above it.
Click the flag.
Since the storefront window is transparent,
you'll see the flying sprites.
Scratch is more than just a programming language.
It's a community of like-minded users
who share projects, inspiration, and encouragement.
Join in by filling out your profile page
with what you like to do
and what you're working on in Scratch.
Never share personal information
like your home address or last name
on Scratch or any internet site.
Now it's your turn.
Add pick random blocks to the y values
of your go to and glide blocks.
Add a set size to block with a pick random block
to randomly change the size of the sprite.
Then, add a go to front block
and a when flag clicked event to the storefront sprite
to make your clones show through the store window.
Sign in to track your progress and earn badges