CHAPTER 4
Moving and Looping
Blastoff! I love a rocket launch, and witnessing astronauts blast off on a NASA, SpaceX, or Blue Origin spacecraft is an exciting mix of sights and sounds. The animated scene you create in this chapter introduces you to your second big idea in coding: repetition. You can make an object move by placing a move command inside a repeat loop. Repeating small movements creates the effect of continuous motion. Repeat loops can execute a set number of times or keep looping forever (until you stop the program running).
In the Tiny Rocket Launch project, you’ll craft a simple scene with a background and one sprite. You’ll write code so that when the user inputs a click the green flag, the rocket launches and moves skyward in a repeat loop until it disappears. The sprite has more than one costume, and you’ll use those when you write code to animate the moving rocket with different looks. You’ll also use coordinates (a math name for the location of an object) to set the rocket’s starting position in the scene. And you’ll add a sound to hear the blastoff. Let’s launch!

Brainstorm
Brainstorm the design of your program by thinking about the overall look of your scene and what you’d like to launch or float up into space — a basketball, or maybe a robot. The end users — the people who will interact with your program — will play with the scene, seeing and hearing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access