Senior Editor Elizabeth Dowsett Senior Designers Owen Bennett and Clive Savage Pre-production Producer Rebecca Fallowfield Producer Zara Markland Managing Editor Sadie Smith Managing Art Editor Ron Stobbart Publisher Julie Ferris Art Director Lisa Lanzarini Publishing Director Simon Beecroft DK Digital Content, London Digital Producer William Jones DK Digital Operations, Delhi First American Edition, 2017 Published in the United States by DK Publishing Hudson Street, New York, New York 10014 Manish Bhatt, Nain Rawat, Suruchi Bhatia, Manjari Hooda Published in Great Britain by Dorling Kindersley Limited. eISBN: 9781465472083 Page design copyright 2017 Dorling Kindersley Limited DK, a Division of Penguin Random House LLC & TM 2017 LUCASFILM LTD All rights reserved. Without limiting the rights under the copyright reserved above, no part of this publication may be reproduced, stored in, or introduced into a retrieval system, or transmitted, in any form, or by any means (electronic, mechanical, photocopying, recording, or otherwise), without the prior written permission of the copyright owner. DK books are available at special discounts when purchased in bulk for sales promotions, premiums, fund-raising, or educational use. For details, contact: DK Publishing Special Markets, Hudson Street, New York, New York 10014 SpecialSales@dk.com A WORLD OF IDEAS: SEE ALL THERE IS TO KNOW www.dk.com www.starwars.com
USING SCRATCH
TM
PROJECTS CODING written by JON WOODCOCK illustrated by JON HALL
INTRODUCTION Contents You can dip in and out of this book and make whichever games you like. However, if you're new to Scratch, it's best to work through the games in the order they appear. This will help you build a thorough understanding of how Scratch works. Foreword by Kiki Prottsman Computer Coding What is Scratch? Exploring Scratch Databank: Using Images in Scratch Databank: Using Sound in Scratch A pleasure to meet you. I am See-Threepio, human-cyborg relations. Jetpack Adventure Build-a-Droid Cargo Bay Chase
CONTENTS Use the Force! Glossary How to Get Scratch
Just the beginning, this is.
Secret Spy Mission
How to use this book Scratch is about inventing, experimenting, and having fun. The projects in this book use Star Wars themes, but you can draw your own pictures and record your own sounds. There are also plenty of ready- made images and sounds in the Scratch libraries loaded and waiting for you to use and even customize. Asteroid Dash To learn how to draw your own sprites, see pages and
Use your imagination to bring your own ideas to life, just like Anakin Skywalker did. He used spare parts to build his own droidcalled C-3PO!
FOREWORD Foreword Growing up in a world where computers are part of everything from spaceships to microwaves, we can be sure that technology is here to stay! If you know how to use computers, the universe opens up and shows you everything that is possible. When you learn how to program computers, you can make the impossible feel real, too. No one knows this better than the creative teams behind the Star Wars movies. Even back in 1977, before tablets and smartphones, Star Wars showcased detailed animation programs written by an extremely intelligent computer artist named Larry Cuba. His passion and imagination helped to launch an industry that has caused generations of moviegoers to believe in a freighter ship with three droid brains and holoprojectors that recreate galaxies in the palm of your hand. Today, more than years later, technology has come so far that kids just like you can easily create programs to keep yourselves entertained, help make difficult decisions, or solve problems. Surprisingly, the skills to create this kind of life-altering software don't have to begin in the classroom. These skills start with a passion for experimentation and a willingness to make mistakes. Like exploring the galaxy, programming is a learning experience. THE BEST DISCOVERIES HAPPEN WHEN YOU ARE CONFIDENT ENOUGH IN YOURSELF TO WALK INTO THE UNKNOWN AND TAKE A LOOK AROUND. Make a move. See what happens. You dont need to know everything about your environment before you start building something new. If your creation fails, learn from your mistakes and keep going. Be as proud of the problems that you work hard to solve as you are of a program that has no errors at all. With this book, you carry with you a guide to one of the worlds most beloved block- based programming languages: Scratch. Scratch was developed as a way of allowing people to express themselves through stories and games, using simple, puzzlelike code. Although Scratch was created for children ages eight and up, it was later
FOREWORD
adopted in college classrooms as a way of teaching the basics of computer science without the worry of having to learn a complicated programming environment. Now, you get to benefit from this simple-to-use software, as you drop yourself into the many exciting worlds of Star Wars. With detailed and easy-to-follow lessons by Jon Woodcock, Star Wars Coding Projects will help you learn basic coding concepts as you dive into fun and playful programs. YOU MIGHT FEEL LIKE YOURE PLAYING A GAME, BUT IN REALITY, YOURE DEVELOPING A NEW WAY OF THINKING AND PROBLEM-SOLVING THAT WILL CHANGE THE WAY YOU LOOK AT THE WORLD. If you remember to keep an open mind and celebrate both your successes and failures, you just might find that a few hours of coding turns into a lifetime of changing what is possible.
KIKI PROTTSMAN Curriculum Development Manager at Code.org Author and YouTube Personality for KIKIvsIT
The Force is calling to you. Just let it in.
COMPUTER CODING Computer Coding In the galaxy far, far away, computers are everywhere: in droids, comlinks, datapads, weapons, and vehicles. In our galaxy, too, computers are all around us: A smartphone is a computer that fits in your pocket. Cars, just like starfighters, contain dozens of computers. But how do these computers know what to do? Its all thanks to coding. What is coding? Coding, or computer programming, is telling a computer what to do. In this book youll learn how to control a computer, like Obi-Wan Kenobi controls a stormtrooper on Tatooine with a Jedi mind trick. Computers need detailed instructions. They must be broken down into simple steps that the computer can follow in order. These steps make up what is called an algorithm. I am fluent in over seven million forms of communication. X-wings have many computers working their different parts. What are computer languages? For a computer to follow the steps of an algorithm, they must be written in a special "programming language" that the computer can understand. There are many programming languages. Some have strange names like C#, C++, Python, and Java, which would suit Star Wars droids and characters. In this book youll learn how to make programs in Scratch, which is a simple programming language for beginners. Code words Algorithm A set of instructions that are followed in order to perform a particular task. Computer programs are based on algorithms. Bug A mistake in a program. Code Computer instructions written in a programming language are often called code. Coding is programming. Debugging Finding and removing bugs from pieces of code. Program Instructions written in a programming language that a computer can follow. Run The command to tell a computer to perform the instructions in a program.