Scratch Programming

Scratch Programming

SCR Foreword by Why choose this book? Sean McManus Mitchel Resnick MIT Media Lab Scratch is a programming language that is widely AT It’s written in plain English used on the Raspberry Pi and in schools and colleges. Put off by the jargon? Don’t worry, we Scratch’s highly visual interface and drag-and-drop Scratch keep things straight forward. commands make it an ideal language for all ages to try CH PROGRAMMIN to program. With Scratch Programming in easy steps at hand, learning programming will be a breeze. This primer introduces you to Scratch fundamentals and Programming It’s easy to follow then walks you through the commands to create games Clear, step-by-step instructions make and animations. Learn to create games that require skill, covers Scratch 2.0 and Scratch 1.4 learning simple. knowledge or quick fi ngers, such as Spiral Rider, Space Swarm, or the classic Hangman game. Add music and special effects to your games, and of course keep score. By the time you’ve fi nished, you’ll be impressing your It’s fully illustrated friends and family with your own computer games! We don’t just tell you how to do it, we Look inside also show you how. Enabling the player to fi re Moving and shooting aliens Space Swarm To enable the player to re, we’ll add a script to the player’s e alien uses the sprite that broadcasts “ re” when the player presses the space bar, pixelate e ect to and we’ll tell our missile sprite to move when it receives that materialize in a broadcast: random position on 1 the right. It makes Click the ship in the Sprite List a zig-zag pattern We use the “ broadcast across the Stage by and wait” block to stop 2 Add a script to the pointing in a random the player from being left-facing direction, able to fi re a second sprite that continuously You can have several missile while the fi rst checks for the spacebar making eight scripts on the same one is still on the screen. being pressed, and then movements, and then sprite, and you can use If we put a “broadcast broadcasts “ re” and changing direction, the green fl ag to start 7 and wait” block inside waits when it is until it reaches the left of the Stage. e picture shows paths in any of them. It’s in full color our movement script, di erent colors, drawn with the pen: the player wouldn’t be 3 1 able to move while a Click the missile sprite in the Sprite List Click the alien in the Sprite List. Add the when green missile was on screen. If ag clicked block and a block to set the size of your 4 This book’s printed in color to make it we used the “broadcast” Add this script to your sprite. Mine is 50% block instead, when the 175 sprite, to hide the missile player pressed space a when the game starts, 2 Fix the rotation style to left-right, using the 174 second time, the missile and position it behind would jump back to the set rotation style left-right block in Scratch simpler to use and easier on the eye. ship and start again. the ship 2.0. In Scratch 1.4, use the settings above the Blocks Palette instead (see Chapter 2) 5 Add a script for when the broadcast “ re” is 3 Add a forever block. e received. We don’t want alien is always moving. When to re when the player it’s dead, it’s hidden, but still G has been hit, so we wrap keeps moving everything in an if block If you’ve used a different alien sprite to me, adjust that checks for this. e 4 Inside your the size of the sprite in script moves the sprite to this script as appropriate. the ship’s position, and forever bracket add the blocks Smaller aliens make it then lowers it slightly, so easier for the player to that put your the missile comes from avoid hitting them, but the ship and not the sprite in a make it harder for the pilot’s head. e loop random position missile to hit them too. moves the missile right on the right of And it’s fantastic value Using 20 steps for the until it’s o screen the screen and missile movement makes use the pixelate it faster than anything 6 e ect to make it else in the game. Click that last script to see the missile re appear Do we need to say any more? Let these icons make it even easier PLAIN ENGLISH £10.99 UK / $14.99 US / $16.95 CN Wherever you see one of these icons you know there’s a handy tip to spice up your learning, fl ag something to remember or ward you away from potential dangers. EASY TO FOLLOW ISBN-13:978-1-84078-612-5 5 1 4 9 9 I was extremely happy with the In Easy Steps series and have purchased several of their guides. Their FULLY ILLUSTRATED “get it done” tutorials provide quick and easy reference material for when I’m programming or designing. “Lowter - Webmaster ezine IN FULL COLOR 9 78184078 6125 www.ineasysteps.com” Covers MIT new Ve Liked this book? More titles rsion Learn to program with Scratch a t h m c g r m i k e Building to Stay Ahead In Easy Steps red! Androidentor - no codingApps requi Scratch makes it easy to create using App Inv your own games, animations, GENERAL music, art or applications. It’s the Computer Basics Laptops for Seniors perfect way to learn programming Computing for Seniors Mac Basics H PLAIN ENGLISH because it takes away a lot of the OW FOLLL iMac MacBook EASY TO USTRATRAATED complexity. That means you can FULLY ILL COLOR Internet for Seniors Upgrading and Fixing a PC IN FULL COL focus on having great ideas and bringing them to life. With this DIGITAL LIFESTYLE book as your companion, you’ll Android Tablets iPad learn how to: Cloud Computing iPhone Digital SLR Photography Samsung Galaxy Tab Design, build and share your DESIGN & GRAPHICS • own programs Illustrator Photoshop • Create addictive arcade InDesign Photoshop Elements games, quizzes and word OFFICE & ACCOUNTING games Accounts & Bookkeeping Microsoft PowerPoint Make computer-generated art 7 Microsoft Excel Microsoft Project • Microsoft Offi ce Microsoft Word Play your favourite music and • compose your own tunes PROGRAMMING & WEB DEVELOPMENT Building Android Apps JAVA Use variables, lists, loops, • C++ Programming JavaScript broadcasts and operators to Dreamweaver PHP & MySQL create sophisticated software Get to No.1 on Google SQL HTML5 Web Design Avoid common programming • pitfalls and bugs OPERATING SYSTEMS Interact with webcam video Linux Windows 8 • and the sensors on a PicoBoard Mac Tips, Tricks & Shortcuts Windows 8 for Seniors Windows 7 Windows 8 Tips, Tricks & Shortcuts This book is an in-depth guide In Easy Steps ebooks Follow us to both the new web-based now available to download onto your Scratch 2.0, and Scratch 1.4, as computer, tablet and smartphone from @InEasySteps In Easy Steps used on the Raspberry Pi. With no www.ineasysteps.com Visit our website for information on our prior knowledge needed, this book titles, free chapters, offers, user forum and to leave feedback. takes you from scratch Get 20% off any In Easy Steps book to Scratcher! Go to www.scratch.ineasysteps.com & quote “SCRATCH” coupon code at checkout (P & P extra) Contents Foreword by Mitchel Resnick 7 1 Introducing Scratch 9 What is Scratch? 10 Which version of Scratch? 11 Starting on the Raspberry Pi 12 Creating a Scratch account 13 Using the Scratch screen 14 Exploring the blocks 16 Changing the backdrop 18 Creating your first program 20 Saving your project 23 Opening projects 25 Opening shared projects 26 2 Drawing with Scratch 27 Understanding coordinates 28 Changing a sprite’s position 30 Using the pen 31 Drawing a house in Scratch 33 Using directions to move 35 Keeping sprites upright 36 Drawing using directions 38 Making shapes using Repeat 39 Putting loops inside loops 40 Creating Rainbow Painter 41 3 Spiral Rider 43 Introducing Spiral Rider 44 Using the green flag 45 Creating variables 46 Drawing a spiral 48 Changing the background 51 Adding sprites 52 Animating the crab 54 Enabling keyboard control 56 Making the fish move 58 Adding Game Over messages 61 4 Super Dodgeball 63 Introducing Super Dodgeball 64 Setting up the variables 65 Preparing for the game start 67 Using coordinates to move 68 Adding more images 70 Renaming sprites 71 Making random numbers 72 Moving the ball 73 Copying and deleting sprites 75 Adding the energy meter 78 Painting in Scratch 80 Using Paint tools 82 Using colors 84 Using vectors in Scratch 2.0 85 Making the ice cream appear 86 Enabling the player to score 88 Tweaking the gameplay 90 5 Cosmic Chorus 91 Introducing Cosmic Chorus 92 Adding sprites and costumes 93 Preparing Cosmic Chorus 96 Adding sounds to a sprite 97 Sounds in Scratch 1.4 99 Recording in Scratch 1.4 100 Playing sounds 101 Making Gobo sing 102 Using broadcasts 103 Conducting the Gobo 104 Adding more Gobos 105 Playing music in Scratch 107 Adding the singing soloist 108 Adding a title screen 110 Enabling the title screen 111 Making your own tunes 112 London Bridge 114 6 Quiz Break 115 Introducing Quiz Break 116 Preparing for Quiz Break 117 Drawing the timer 119 Moving the clock hand 121 Adding a rising sound effect 124 Asking questions 125 Joining text to greet players 126 Preparing the quiz 127 Making the questions 128 Checking the answers 130 Reporting the scores 132 Adding the victory dance 133 7 Hangman 135 Introducing Hangman 136 Importing the images 137 Making the gallows 138 Making the alphabet sprite 140 Creating the variables 141 Setting up the gallows 142 Losing the game 143 Adding graphic effects 144 Creating the main script 146 Creating lists 149 Using lists 150 Setting up the variables 152 Showing the game board 155 Testing the game board 158 Asking for the player’s guess 159 Checking the letter 161 Game over 164 8 Space Swarm 165 Introducing Space Swarm 166 Preparing

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    35 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us