Randomness adds variety to your games. When developing a games, you will often want to add some element of random chance whether it be in obstacles, enemy artificial intelligence, or some other feature. This movie shows how to add some randomness to the speed of the rocks falling down from the top of the screen in our game.
- [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 to modify the speed…by picking a random number.…
He starts with demonstrating how to create your first project and gather the artwork (aka sprites) and other assets you'll need to build it. Todd then reviews the prebuilt scripts, the bits of code that control the logic of your Scratch projects, and explains how to use the different script types for different functions, such as animating sprites, responding to events such as button clicks, and comparing values. In chapter 3, he covers costumes, and in chapter 4, he shows how to load and play sounds. Finally, he shows how to put it all together into a complete web game, which you can then share with the Scratch community.
- What is Scratch?
- Creating your first project
- Choosing a backdrop for your application
- Creating sprites (reusable graphics) in Scratch
- Working with scripts: animating objects, responding to events, and checking logic
- Switching sprite costumes
- Changing the appearance of sprites with custom-drawn costumes
- Playing sounds
- Building a game with Scratch
Skill Level Beginner
Teaching iOS Programming to Kidswith Todd Perkins1h 2m Beginner
Teach Kids Programming with PHPwith Mark Niemann-Ross1h 39m Beginner
1. Get Started with Scratch
5. Build a Game
Next steps2m 36s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.