From the course: Learning Scratch

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Randomness

Randomness - Scratch Tutorial

From the course: Learning Scratch

Start my 1-month free trial

Randomness

- [Voiceover] Currently, all the rocks fall at the same speed. But what if we wanted to add an element of randomness to make them go at different speeds each time the rock falls down? Let's look at how to do that. I'm going to head over to "data" and I'm going to click on "Make a Variable." Keep in mind that I have the rock selected. So you definitely want to be on the rocks here and then you want to click "Make a Variable." This is going to be for this sprithe only. And the variable name is going to be "speed." So do that and click "OK." So now we have a speed variable. When we initially start, I want to set the speed to -10 so I'm going to drag out a set of speed script right above the hide script. Right underneath "When green flag clicked." I'm going to set speed to -10. So that's going to be the default speed. Each time I create a clone though, I'm going to modify the speed. So what I'm going to do, is bring out "set speed to" right under create clone of myself and then I'm going…

Contents