About this ebook
Related to Scratch Cookbook
Related ebooks
Hello Scratch!: Learn to program by making arcade games Rating: 0 out of 5 stars0 ratingsScratch 2.0 Game Development - HOTSHOT Rating: 1 out of 5 stars1/5Fun Games with Scratch 3.0: Learn to Design High Performance, Interactive Games in Scratch (English Edition) Rating: 0 out of 5 stars0 ratingsLearning Android Game Development Rating: 0 out of 5 stars0 ratingsScratch 1.4: Beginner's Guide Rating: 0 out of 5 stars0 ratingsScratch 2.0 Programming Rating: 3 out of 5 stars3/5Scratch 2.0 Beginner's Guide Second Edition Rating: 4 out of 5 stars4/5HTML 5 Shoot 'em Up in an Afternoon Rating: 0 out of 5 stars0 ratingsCode-It Workbook 2: Choices In Programming Using Scratch Rating: 0 out of 5 stars0 ratingsMission Ruby Rating: 0 out of 5 stars0 ratingsLet's Get Coding Rating: 0 out of 5 stars0 ratingsInstant HTML5 2D Platformer Rating: 0 out of 5 stars0 ratingsGetting Started with Coding: Get Creative with Code! Rating: 0 out of 5 stars0 ratingsDesigning Digital Games: Create Games with Scratch! Rating: 0 out of 5 stars0 ratingsA Book For Young Programmers On Scratch. Rating: 5 out of 5 stars5/5HTML5 Game Development HOTSHOT Rating: 0 out of 5 stars0 ratingsCode-It Workbook 1: First Steps in Programming using Scratch Rating: 0 out of 5 stars0 ratingsTeaching Primary Programming with Scratch Pupil Book Year 4 Rating: 0 out of 5 stars0 ratingsCoding for Minecrafters: Unofficial Adventures for Kids Learning Computer Code Rating: 0 out of 5 stars0 ratingsGet Started With Arduino: Robots, Musical Instruments, Smart Displays and More Rating: 0 out of 5 stars0 ratingsjQuery Game Development Essentials Rating: 0 out of 5 stars0 ratingsAdventures in Python Rating: 0 out of 5 stars0 ratingsCoding for Kids Ages 10 and Up: Coding for Kids and Beginners using html, css and JavaScript Rating: 5 out of 5 stars5/5Getting Started with Coding: Get Creative with Code! Rating: 0 out of 5 stars0 ratingsLearning NGUI for Unity Rating: 0 out of 5 stars0 ratingsCoding Programs For Kids: Parents Guidebook: How Your Child Can Learn To Code And The Benefits For Their Future: Parenting Rating: 0 out of 5 stars0 ratingsCode-It Workbook 3: Algorithm to Code Using Scratch Rating: 0 out of 5 stars0 ratingsCreating Digital Animations: Animate Stories with Scratch! Rating: 0 out of 5 stars0 ratings
Programming For You
Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5SQL All-in-One For Dummies Rating: 3 out of 5 stars3/5Linux: Learn in 24 Hours Rating: 5 out of 5 stars5/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5Python Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5Python: Learn Python in 24 Hours Rating: 4 out of 5 stars4/5Learn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5JavaScript All-in-One For Dummies Rating: 5 out of 5 stars5/5Excel 101: A Beginner's & Intermediate's Guide for Mastering the Quintessence of Microsoft Excel (2010-2019 & 365) in no time! Rating: 0 out of 5 stars0 ratingsBeginning Programming with Python For Dummies Rating: 3 out of 5 stars3/5Godot from Zero to Proficiency (Foundations): Godot from Zero to Proficiency, #1 Rating: 5 out of 5 stars5/5Learn NodeJS in 1 Day: Complete Node JS Guide with Examples Rating: 3 out of 5 stars3/5Microsoft Azure For Dummies Rating: 0 out of 5 stars0 ratingsBeginning Programming with C++ For Dummies Rating: 4 out of 5 stars4/5Teach Yourself C++ Rating: 4 out of 5 stars4/5Python for Data Science For Dummies Rating: 0 out of 5 stars0 ratingsPython Data Structures and Algorithms Rating: 5 out of 5 stars5/5The 1 Page Python Book Rating: 2 out of 5 stars2/5
Reviews for Scratch Cookbook
0 ratings0 reviews
Book preview
Scratch Cookbook - Brandon Milonovich
Table of Contents
Scratch Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
More information
Conventions
Reader feedback
Customer support
Errata
Piracy
Questions
1. Getting Started with Scratch
Introduction
Starting up Scratch
Getting ready
How to do it…
How it works…
See also
Deleting the default sprite
Getting ready
How to do it…
There's more…
Adding a custom sprite
Getting ready
How to do it…
Adding a pre-made sprite
Getting ready
How to do it…
There's more…
See also
Changing the stage background
Getting ready
How to do it…
There's more…
See also
The Hello World project
Getting ready
How to do it…
How it works…
There's more…
Adding some motion
Special sprite settings
Pointing towards the mouse
Duplicating code
See also
2. Storytelling
Introduction
Adding words to a sprite
Getting ready
How to do it...
How it works...
See also
Adjusting the timing
Getting ready
How to do it...
How it works...
There's more...
See also
Sprites interacting with other sprites
Getting ready
How to do it...
How it works...
There's more...
See also
Basic broadcasting and receiving
Getting ready
How to do it...
How it works...
The broadcast block
The receive block
More about the code
There's more...
Triggering an event with a click
Changing the background
See also
Resetting parts of a program
Getting ready
How to do it...
How it works...
There's more...
See also
Other fun graphic effects
Getting ready
How to do it...
How it works...
There's more...
Fisheye
Whirl
Pixelate
Mosaic
Brightness
Ghost
See also
3. Adding Animation
Introduction
Changing sprite costumes
Getting ready
How to do it...
How it works...
There's more…
Making it dance
Checking the costume number
Switching to a particular costume
See also
Switching backgrounds in a story
Getting ready
How to do it...
How it works...
See also
Adding graphic effects to backgrounds
Getting ready
How to do it...
How it works...
There's more...
A finished message
Adding other effects
Animating the button
See also
Keyboard input to a program
Getting ready
How to do it...
How it works...
There's more...
Using better defined variables
See also
Getting the mouse position
Getting ready
How to do it...
How it works...
There's more...
4. Basic Gaming
Introduction
Creating a moving object
Getting ready
How to do it...
How it works...
There's more…
The simple way
Adding another ball
Getting ready
How to do it...
How it works...
There's more...
See also
Object interaction with a background
Getting ready
How to do it...
How it works...
There's more...
See also
User interaction with a game
Getting ready
How to do it...
How it works...
Using mouse control
Getting ready
How to do it...
How it works...
There's more...
Keeping score
Getting ready
How to do it...
How it works...
Objects disappearing
Getting ready
How to do it...
How it works...
See also
Building a maze
Getting ready
How to do it...
How it works...
There's more...
Using the timer
Getting ready
How to do it...
How it works...
See also
5. Spicing up Games
Introduction
Tracking the best score or time
Getting ready
How to do it...
How it works...
There's more…
Keeping a high score list
Getting ready
How to do it...
How it works...
There's more…
See also
Adding more levels
Getting ready
How to do it...
How it works...
There's more...
6. Bringing in Sound
Introduction
Playing sounds
Getting ready
How to do it...
How it works...
There's more…
See also
Importing a new sound
Getting ready
How to do it...
How it works...
There's more…
See also
Recording a sound
Getting ready
How to do it...
See also
Playing drums and notes
Getting ready
How to do it...
How it works…
There's more…
Adjusting volume
Getting ready
How to do it...
See also
Fading volume out
Getting ready
How to do it...
See also
Changing the tempo
Getting ready
How to do it...
Interactive note playing
Getting ready
How to do it…
How it works…
7. Integrating PicoBoards
Introduction
Setting up the sensor board
Getting ready
How to do it...
How it works...
See also
Getting values from the sensor board
Getting ready
How to do it...
How it works...
There's more...
See also
Working with the slider
Getting ready
How to do it...
There's more...
See also
Integrating the light sensor
Getting ready
How to do it...
See also
Integrating the sound sensor
Getting ready
How to do it...
How it works...
There's more…
See also
Measuring resistance
Getting ready
How to do it...
How it works...
There's more...
The sensor board button
Getting ready
How to do it...
Checking other connections
Getting ready
How to do it…
There's more…
8. Programming to Calculate
Introduction
Generating Fibonacci numbers
Getting ready
How to do it...
How it works...
See also
Sieve of Eratosthenes
Getting ready
How to do it...
How it works...
See also
Creating a password generator
Getting ready
How to do it...
How it works...
Other Scratch calculations
Getting ready
How to do it…
9. Project Remixing
Introduction
Importing parts of other projects
Getting ready
How to do it...
Drawing with the pen
Getting ready
How to do it...
See also
Remixing the pen project
Getting ready
How to do it...
A. Collaboration
Introduction
The online Scratch community
Getting ready
How to do it…
How it works...
See also
Creating an account
Getting ready
How to do it...
See also
Sharing projects
Getting ready
How to do it...
See also
Sharing Scratch 1.4 projects
Getting ready
How to do it...
Downloading projects
Getting ready
How to do it...
Index
Scratch Cookbook
Scratch Cookbook
Copyright © 2013 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: July 2013
Production Reference: 1170713
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-84951-842-0
www.packtpub.com
Cover Image by Sandeep Vaity (<[email protected]>)
Credits
Author
Brandon Milonovich
Reviewers
David Busby
Stamati Crook
Andrew Johns
Martina Kabátová
Pedro Neves Rito
Forest Y. Yu
Acquisition Editor
Joanne Fitzpatrick
Commissioning Editor
Llewellyn Rozario
Lead Technical Editor
Anila Vincent
Technical Editors
Shashank Desai
Krishnaveni Haridas
Mausam Kothari
Pushpak Poddar
Rikita Poojari
Amit Ramadas
Project Coordinator
Hardik Patel
Proofreaders
Maria Gould
Paul Hindle
Indexer
Monica Ajmera Mehta
Graphics
Ronak Dhruv
Production Coordinator
Aparna Bhagat
Cover Work
Aparna Bhagat
About the Author
Brandon Milonovich completed his Master's degree in Teaching and Curriculum with emphasis in Mathematics Education in December 2012 at Syracuse University in central New York. Prior to attending Syracuse, Brandon earned his Bachelor's degree in Adolescent Mathematics Education at The College of Saint Rose in Albany, NY. Brandon grew up in upstate New York with an interest in mathematics and computer science at a young age. Brandon has experience of teaching mathematical concepts to students using Scratch in third through fifth grade, as well as experience of teaching mathematics at the middle school, high school, and university level.
It was during Brandon's time at Saint Rose that he began his work with Scratch through an internship program with Computer Science professor Helen Albanese. In coordination with three Albany City School District teachers, Brandon developed an after-school program centered on programming in Scratch for at-risk youth. The program expanded the following year to include a broader age range of students. Now, Brandon works towards making learning Scratch more accessible within the classroom itself, both with traditional methods and flipped classroom-blended learning style concepts, to build the mathematical foundation students need to be successful 21st century learners. Brandon believes in sharing of information as broadly as possible, and so has presented with his colleagues at numerous conferences and workshops on Scratch, and hopes to continue to do so.
For more information on Brandon, or to contact him, visit http://www.bmilo.com.
I would like to thank all of those who have helped me along the way in both the process of writing this book, as well as becoming qualified to write it. Special thanks to Helen Albanese for her continued pushing to work more with Scratch and the opportunities she has provided, as well as a thank you to every professor I had at both the undergraduate and graduate level who have guided me along the way. Thanks also to the Albany City School District for opening its classrooms, particularly to Laurie Ellis, Stephen Costello, Alice Florence, and Timothy Fowler. The greatest thanks of all to my family for their constant support, guidance, and help. Without the amazing group of people I've been surrounded by throughout my life, I would have had little chance of success.
About the Reviewers
David Busby has been a Linux system's admin for around 12 years now and almost always being in a varied role over the years be it development, network admin, support, DBA changing onto a day-to-day basis.
Whenever time permits, he contributes to the EPEL packages for OpenStack and generally follows OpenStack's progress as much as possible.
He has an interest in Infosec, and as a result is generally paranoid about security. He is also familiar with Metasploit, sqlmap, john, and oclHashCat, and has also written a few python tools, and experimented in Golang.
He holds a 2nd Dan black belt in Ju-Jitsu and assists with teaching at a local non-profit club. He also helps to teach a computing class for children at a local school, using Raspberry Pi.
Stamati Crook is a professional programmer with his own software house and consultancy on the south coast of England. He has been involved in teaching Scratch to children at local primary schools and also hopes that his own three children will begin to show more interest in creating games rather than just playing them. His wife, Kathy, also uses Scratch daily in her classroom and you can find lesson plans and resources for children, parents, and teachers learning and teaching Scratch at http://www.redware.com/scratch.
Andrew Johns has been a web developer since 1999. He became a STEM Ambassador and Code Club volunteer in 2012, teaching Scratch to primary school children. He currently works for London-based design agency, Pretty, as a Technical Lead. This is the first book for which he has acted as a Technical Reviewer.
Martina Kabátová is a teacher and a researcher in the field of Computer Science education. After completing her PHD, she began to work as an Assistant Professor at Comenius University in Bratislava, Faculty of Mathematics, Physics and Informatics, Department of Informatics Education. Among her responsibilities are several university lectures on programming, educational robotics, and research methodology. Currently, she focuses on educational programming (especial for very young children). She is an author of several study materials and many conference papers dealing with various aspects of Computer Science education. In 2013, she co-authored a book Transforming Schools in Digital Age, with Prof. Ivan Kalaš, which summarizes the role of digital technology in education. Martina Kabátová also illustrated this book and she is the author of many illustrations for other computer science textbooks, educational software, and MicroWorlds, and for the Slovak Bebras contest for children in informatics.
Pedro Neves Rito has been working as a professional trainer in the area of information technology and communications for more than 16 years, and as a teacher in higher education for the last six years. He has a Master's degree in Multimedia in Education and is currently a student of the Doctoral program in information systems and technologies. He has used Scratch as a tool for an introduction to programming. Lately, he's been exploring physical computing and Scratch, particularly the use of the Arduino, with the perspective of building activities for primary students. This work has been developed with the help of teachers of different levels of education.
He is currently also an assistant professor at Polytechnic Institute of Viseu, at the School of Education, working in the Department of Communication and Art, in the area of Information Technology and Communication. He works with higher education students, particularly in plastic arts and multimedia, and those pursuing primary education courses (future teachers) and also some that are pursuing Master's courses. In addition to being a teacher in these areas, he has supported a few initiatives outside school that are related to the use of Scratch.
He has started some individual projects, including the writing of two books, which is ongoing. In recent years, he has dedicated most of his time to contributions, by publishing and presenting scientific articles at conferences and some other documents to print media.
Forrest Y. Yu is an author of two books on operating systems. He has a wide range of interests and experiences, including desktop applications, web services, LBS, operating systems, cloud computing, and so on. Recently, he has been working with Amazon building the next generation information security platform and tools. He has a blog http://forrestyu.com/ where you can find more information about him.
www.PacktPub.com
Support files, eBooks, discount offers and more
You might want to visit www.PacktPub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
Support files, eBooks, discount offers and morehttp://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.
Why Subscribe?
Fully searchable across every book published by Packt
Copy and paste, print and bookmark content
On demand and accessible via web browser
Free Access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
Preface
If you're relatively new to programming, or are just looking for a programming language that allows you to explore your visual and creative side, Scratch will be a lot of fun for you. Scratch was developed as a project of the Lifelong Kindergarten Group at the MIT Media Lab to make programming more accessible to young and/or new programmers.
As you work through this book, you'll gain a greater understanding of how to work with Scratch while simultaneously developing an understanding of fundamental programming principles that you'll want to know when you eventually begin to work with other programming languages.
You'll notice pretty quickly that this book is written focusing on Scratch 2.0, the newest