scratch programming in easy steps pdf sampler
Post on 15-May-2015
Embed Size (px)
DESCRIPTIONDownload this free sample from the book Scratch Programming in Easy Steps by Sean McManus. It includes the table of contents, the foreword by Mitchel Resnick, Chapter 1 in full, and the index. Scratch is a programming language widely used in schools and education, and makes it easy for anyone of any age to learn to program.
- 1.S e a nM c M a n u sForeword by Mitchel Resnick MIT Media LabScratch Programming covers Scratch 2.0 and Scratch 1.47PLAIN ENGLISH EASY TO FOLLOW FULLY ILLUSTRATEDIN FULL COLOR
2. Learn to program with Scratch Scratch makes it easy to create your own games, animations, music, art or applications. Its the perfect way to learn programming because it takes away a lot of the complexity. That means you can focus on having great ideas and bringing them to life. With this book as your companion, youll learn how to: Design, build own programsand share your arcade Create addictiveand word games, quizzes gamescreate sophisticated software Avoid common programming pitfalls and bugs Interact video and the with webcamPicoBoard sensors on a This book is an in-depth guide to both the new web-based Scratch 2.0, and Scratch 1.4, as used on the Raspberry Pi. With no prior knowledge needed, this book takes you from scratch to Scratcher!7 Make computer-generated art Play your favourite compose your own music and tunes Use variables, broadcasts andlists, loops, to operators 3. Contents Foreword by Mitchel Resnick71Introducing Scratch9What is Scratch? Which version of Scratch? Starting on the Raspberry Pi Creating a Scratch account Using the Scratch screen Exploring the blocks Changing the backdrop Creating your first program Saving your project Opening projects Opening shared projects10 11 12 13 14 16 18 20 23 25 262Drawing with Scratch3Spiral RiderUnderstanding coordinates Changing a sprites position Using the pen Drawing a house in Scratch Using directions to move Keeping sprites upright Drawing using directions Making shapes using Repeat Putting loops inside loops Creating Rainbow PainterIntroducing Spiral Rider Using the green flag Creating variables Drawing a spiral Changing the background Adding sprites Animating the crab Enabling keyboard control Making the fish move Adding Game Over messages27 28 30 31 33 35 36 38 39 40 4143 44 45 46 48 51 52 54 56 58 61 4. 4Super Dodgeball Introducing Super Dodgeball Setting up the variables Preparing for the game start Using coordinates to move Adding more images Renaming sprites Making random numbers Moving the ball Copying and deleting sprites Adding the energy meter Painting in Scratch Using Paint tools Using colors Using vectors in Scratch 2.0 Making the ice cream appear Enabling the player to score Tweaking the gameplay5Cosmic Chorus Introducing Cosmic Chorus Adding sprites and costumes Preparing Cosmic Chorus Adding sounds to a sprite Sounds in Scratch 1.4 Recording in Scratch 1.4 Playing sounds Making Gobo sing Using broadcasts Conducting the Gobo Adding more Gobos Playing music in Scratch Adding the singing soloist Adding a title screen Enabling the title screen Making your own tunes London Bridge63 64 65 67 68 70 71 72 73 75 78 80 82 84 85 86 88 9091 92 93 96 97 99 100 101 102 103 104 105 107 108 110 111 112 114 5. 6Quiz Break7Hangman1358Space SwarmIntroducing Quiz Break Preparing for Quiz Break Drawing the timer Moving the clock hand Adding a rising sound effect Asking questions Joining text to greet players Preparing the quiz Making the questions Checking the answers Reporting the scores Adding the victory danceIntroducing Hangman Importing the images Making the gallows Making the alphabet sprite Creating the variables Setting up the gallows Losing the game Adding graphic effects Creating the main script Creating lists Using lists Setting up the variables Showing the game board Testing the game board Asking for the players guess Checking the letter Game overIntroducing Space Swarm Preparing the images Adding sound effects Creating the variables Programming the hero Enabling the player to fire Moving and shooting aliens Finishing touches Adding the high score115 116 117 119 121 124 125 126 127 128 130 132 133136 137 138 140 141 142 143 144 146 149 150 152 155 158 159 161 164165 166 167 169 170 171 174 175 177 178 6. 9Scratch hardware projects Using a webcam Using video direction Going Batty Using a PicoBoard Making a clap-o-meter Making Night Flight Using the Raspberry Pi GPIO10Seven shorties11Making and sharing projects179 180 181 182 184 185 186 189191Keepy-Uppy192 Shop Cat 194 Penguin Patter 197 Ransom Writer 198 Maze Mania 201 Abstract Artist 202 Photo Safari 203Making your own programs Common bugs Sharing your projects Resources Acknowledgements 205 206 208 209 210 210Acknowledgements210 Index211 7. How to use this book Welcome to the wonderful world of Scratch! This book will show you some of the great projects you can build with Scratch, and will give you the skills and knowledge you need to start designing your own projects. The book has been written so that each chapter teaches you something new, and builds on the previous chapters. For that reason, the best way to use this book is to work through the chapters in the right order. Feel free to experiment as you go, though: there are lots of things you can do to customize and improve the examples in this book, and thats a big part of what Scratch is all about. If you need advice on something that hasnt been covered yet, or you want to revise something you read earlier, consult the index for more information. Heres whats in store:sprite here. In your first program, it goes for a quick walk.youll how Scratch, to In Chapter 2,around learnStage, to draw withmake bitshowyour move sprites the and how to of program repeat. The final project is art program Rainbow Painter, which leaves a colorful line behind your mouse. In Chapter 3, Spiral Rider is your first game. Youll learn how to enable keyboard control of a sprite, and how to detect when the players character touches something else, and youll discover how to remember information in a program.4, you how to build In Chapterlotsthe Dodgeball gameatshows Youll learn how toa game with of sprites moving once. design your own sprites, how to clone them in Scratch 2.0, how to make random numbers, and how to keep score.5, conduct the Cosmic Chorus. In Chapter useyou get to sounds and musical notes, howYoull see how to recorded to get one sprite to control another, and how to make a title screen.191, learn of are In Chapter canyoull in yourthe basicsand Scratch. Sprites cat objects you use games, youll meet the 8. How to use this book...contd 6, Quiz Break players maths skills In ChapterYoull learn howtestsuse the timer, how to against the clock. to use the operators for maths, and how to join text together.Hangman teaches you how to use In Chapter 7, the game ask the player for information, how to lists in Scratch, how to structure complex programs, and how to write on the Stage.Chapter youll create an arcade game learn In make one8,sprite fire on another, and howand make how to to special effects to include in your game.to use Scratch with your In Chapter 9, youll learn howPicoBoard add-on which webcam, microphone and the20combines several sensors in one Scratch-friendly device. Flap your hands at the screen to wave away the bats and use your Picoboard to control a witchs night flight. Youll also see how to control a light connected to the Raspberry Pi from Scratch.contains programs you can Chapter 10 with and seven short including the games Shop experiment customize, Cat, Maze Mania, Photo Safari and Breakthrough. Chapter 11 gives you advice on creating your own programs, and resources you can use to help you get started. Downloading the examplesThe best way to use this book is to work your way through the chapters in order, creating the examples as you go. Youll learn more about programming, and youll have a chance to customize the examples as you go. If you cant get the examples to work, or if you want to take a shortcut, you can download them. The examples for Scratch 1.4 can be downloaded at the authors website at www.sean.co.uk and the publishers website at www.ineasysteps.com To find the examples for Scratch 2.0, visit the authors profile on the Scratch website. You can find it at http://scratch.mit.edu/ users/seanmcmanus/ 9. Foreword by Mitchel Resnick Mitchel Resnick is Professor of Learning Research at the MIT Media Lab. Is it important for all children to learn how to write? After all, very few children grow up to become journalists, novelists, or professional writers. So why should everyone learn to write? Of course, such questions seem silly. People use writing in all parts of their lives: to send birthday messages to friends, to jot down shopping lists, to record personal feelings in diaries. The act of writing also engages people in new ways of thinking. As people write, they learn to organize, refine, and reflect on their ideas. Its clear that there are powerful reasons for everyone to learn to write.The recent surge of interest in learning to code, reflected in sites like codecademy.com and code.org, has focused especially on job and career opportunities. It is easy to understand why: the number of jobs for programmers and computer scientists is growing rapidly, with demand far outpacing supply. But I see much deeper and broader reasons for learning to code. In the process of learning to code, people learn many other things. They are not just learning to code, they are coding to learn. In addition to learning mathematical and computational ideas (such as variables and conditionals), they are also learning strategies for solving problems, designing projects, and communicating ideas. These skills are useful not just for computer scientists but for everyone, regardless of age, background, interests, or occupation. Six years ago, my research group at the MIT Media Lab launched the Scratch programming language and online community in an effort to make coding accessible and appealing to everyone.7I see coding (computer programming) as an extension of writing. The ability to code allows you to write new types of things interactive stories, games, animations, and simulations. And, as with traditional writing, there are powerful rea