2. Introduction to Loops
Hey Team, let's get started on Activity 7 of Google CS First Sports!
In this activity, you will build an extreme sports game in which a racer navigates an obstacle course for as long as possible.
You will also learn about the computer science concept called loops.
Loops are commands that make something happen over and over again.
You’ve already used loops in previous projects.
You used the “forever” loop in the "net sports" game to make the ball bounce around over and over again forever.
You used a “repeat” loop in the "batter up" game to determine how many pitches to throw.
In this activity, you’ll learn a few different ways the “forever” loop can be used in a game, and you will also learn about a different kind of loop, called a “repeat until” loop.
A “repeat until” loop can be read in a sentence like this: Repeat these actions until something specific happens.
For example, when running track, you repeat the “run” actions until you touch the finish line.
When you’re at lunch, you repeat the action “eat your food” until you are out of food.
Computer scientists like you use loops in programs that make programs better.
One example is hyper lapse videos.
When you take video with your camera, it often comes out shaky.
Hyperlapse uses built-in stabilization technology to create moving time-lapse videos with a handheld camera that don’t look shaky.
Using Instagram’s hyperlapse app, a user can turn a video into a hyperlapse with a click of a button.
It may seem simple, but there’s a lot of computer science that happens behind the scenes.
First, the app speeds up the video.
This is done by removing frames from the video using a loop.
For example, to make a video play twice as fast, the app removes every other frame from the video.
Then, the app lines up the frames so that the video is smooth.
Finally, it crops the video.
The result is a smooth, enjoyable hyperlapse.
Check out this sweet video of a biker’s adventure.
Thanks to computer science, anyone can create highlight reels of their adventures with the touch of a button.
In this activity, you will use the “repeat until” loop as you program your extreme sports game.
Now, you’ll remix the starter project and sign into Scratch.
Choose the racer you like best, then delete the extra racer sprites from the project.
It's time to start!
Click the starter project link next to this video.
Then, click “remix,” sign in, and delete the extra racer sprites.
When you’re done, come back to this page and click the green arrow to watch the next video.