{% trans 'Watch it here now.' as msg_meta_extra} Random Appearances - Greeting Card - 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.

arrow_back Random Appearances

Transcript

This add-on will show you how to make art elements appear randomly in your Scratch project using the random block.

This example will make a circle sprite appear randomly on the screen and change colors.

But you can use the random block in many different ways, use your imagination!

First, make the sprite change colors forever.

You have created similar code in previous projects like in paint with Terron day four.

Use the change color effect by 25 block inside a forever loop to make the color keep changing.

Now make the sprite appear in a different place each time it changes colors.

Drag out the go to xy block and place it inside the forever loop.

Using this block you can specify exactly where the sprite will show up.

Remember, you can see the x and y coordinates of any position on the stage by hovering over that position with the mouse and looking at the coordinates printed in the lower right corner of the stage.

Since the sprite should appear in a random place each time, use the pick random block found under operators.

You need two pick random blocks, one for the x value and another for the y value.

Drag them both out and place them inside the value spaces in the go to block.

Change the values for the first pick random block to negative 240 and 240 to represent the left and right edges of the screen.

Change the values for the second pick random block to negative 170 and 170 to represent the top and bottom of the screen.

Now, try running your code.

Wow!

The sprite do jumps all over the screen and changes colors really fast!

Next, add a stamp block to make the circle leave a stamp in each place it appears.

Awesome, be sure to add an event to tell the sprite when to start.

Now it's your turn.

Use go to xy and pick random blocks to make the sprite appear randomly throughout your project.

Be creative and incorporate your own ideas.

Choose an Add-On
Party Time!
Make sprites spin and change colors.
Now You See Me...
Using "show" and "hide" make the sprites in your project appear and disappear.
Stage Lights
Change the background based on user input.
Random Appearances
Make art elements appear randomly.
Triangles All the Way Down
Create a fractal with many little triangles.
Spirals
Learn how to create spirals.
Next arrow_forward
Instructions
  1. Choose a recipient for your card, such as a parent, friend, Guru, or Host.
  2. Craft and code a message for that person about CS First.
  3. Create art to enhance your card and show off what you've learned in this club.
Attributions
  • "Crowd down the street" by Guillaume (https://www.flickr.com/photos/guiguibu91/2889883615) -- Licensed by CC BY 2.0 (https://creativecommons.org/licenses/by/2.0/) -- Image scaled up, cropping edges
  • "Greetingcards" by Sotakeit (https://commons.wikimedia.org/wiki/File:Greetingscards.jpg) -- Licensed by Creative Commons Attribution 3.0 Unported (https://creativecommons.org/licenses/by/3.0/legalcode) -- Image scaled up, cropping edges