INTRODUCTION

Welcome to Scratch 2.0 Programming for Teens! Scratch is a programming language developed by the MIT Media Lab to teach programming to children and other first-time programmers. Scratch was initially released in May 2007. It was recently updated as Scratch 2.0, which was released in May 2013. Scratch 2.0 supports the development of computer games, interactive stories, graphic artwork and computer animation, and all sorts of other multimedia projects.

Scratch 2.0 allows new programmers to create programs by snapping together code blocks. Scratch 2.0 consists of a programming language made up of different code blocks and an easy-to-learn graphical development environment that includes a paint application for creating graphics and built-in sound-editing capabilities. Scratch 2.0 also comes with a huge collection of graphics and sound files, all of which you can use to create your own Scratch 2.0 projects.

As demonstrated in Figure I.1, Scratch 2.0 programs are made up of graphical code blocks, which are snapped together to create scripts. Scratch 2.0 code blocks resemble puzzle pieces in the way they snap together. Scratch 2.0 code blocks can only be snapped together in ways that make sense, preventing new programmers from using them in invalid combinations. In this way, Scratch 2.0 enforces proper programming syntax and ensures that new programmers learn the proper way to assemble and formulate programming logic in their scripts.

Figure I.1
Script code blocks are used as the basis for writing scripts that bring applications to life.

image

© 2014 Cengage Learning®

Scratch’s development was inspired by the method that hip hop DJs use to mix and scratch records to create new and unique music. In Scratch 2.0, new programmers are able to create new application projects that incorporate prebuilt code blocks, graphics, and sound files in all kinds of new combinations. Scratch 2.0 lets programmers modify applications on the fly, allowing changes to be made even while Scratch 2.0 applications are running. The result is an interactive, real-time programming environment that encourages experimentation and learning.

This book’s primary goal is to teach you everything you need to know to learn the basics of computer programming with Scratch 2.0. To help accomplish this goal, this book emphasizes learning by doing, which is accomplished through the development of a series of fun and interesting programming projects.

WHY SCRATCH?

Scratch 2.0 is both a programming language and a graphical user environment. It provides everything you need to begin developing computer games, multimedia presentations, interactive stories, graphic artwork, and computer animation. There is nothing to install on your computer; everything is done in your browser window. To get started, all you have to do is open your browser window and type the URL for the Scratch website.

You can use Scratch 2.0 to play digital music and sound effects. Scratch’s building block approach to programming sets it apart from other programming languages. This makes Scratch 2.0 easier to learn. Yet Scratch 2.0 provides plenty of programming power, allowing you to build powerful application projects.

If you aspire to one day become a professional programmer, you will find that Scratch 2.0 provides everything you need to build a foundation from which you can make the transition. Scratch 2.0 also packs all the programming power and punch needed to satisfy the programming needs of most computer enthusiasts and hobbyists.

WHAT’S NEW IN SCRATCH 2.0?

As programming languages go, Scratch 2.0 is a relative newcomer. Scratch 1.0 was released in January 2007 but has been updated a number of times since. The previous edition of this book covered Scratch 1.2, which was released in December 2007. In May 2013, Scratch 2.0 was released.

Scratch 2.0 features numerous enhancements and new features not found in previous versions of Scratch. If you own the previous edition of this book or a different book covering an earlier edition of Scratch, you will definitely benefit from reading this book, which highlights and demonstrates the usage and application of the most important of these enhancements.

The most notable new feature of Scratch 2.0 is that you no longer have to download and install Scratch on your computer to use it. All you need is a web browser and a connection to the Internet. Once you’re connected to the Scratch website, you’ll find the entire Scratch 2.0 programming environment waiting on you, and it is just as fast and reliable as the earlier desktop-based versions of Scratch were. Some of the other new major features of Scratch 2.0 include

image An improved graphical user interface

image Video sensing, which allows Scratch to sense user input (hand and body movement) collected through a computer’s video camera

image The ability to store and retrieve cloud data

image The ability to clone or dynamically create copies of sprites during program execution

image An improved Sound Editor

image Support for vector graphics (in addition to bitmap graphics)

image A backpack feature that facilitates the copying of objects from other people’s projects into your own projects

image The ability to create custom code blocks and enhance program organization using procedures

image New code blocks that provide lots of new capabilities

There are plenty of other changes in Scratch 2.0 than those previously listed—far too many to introduce and cover here. You’ll learn about things like galleries, improved ways of crediting other users when you remix (copy and modify) their projects, and how to follow users by subscribing to their Scratch projects as you make your way through this book.

WHO THIS BOOK IS FOR

Scratch 2.0 Programming for Teens is designed to provide all the instruction that a first-time programmer requires to quickly get up and running. Previous programming experience will certainly be helpful, but it is by no means a requirement of this book. This book makes no assumptions about your computer background other than that you are comfortable working using a web browser to surf the Internet.

This book provides everything you need to get started with Scratch 2.0. Before you know it, you will be creating all kinds of projects, incorporating graphics, sound, and animation. As you learn how to program with Scratch 2.0, you will learn programming principles and techniques that you can later apply to other programming languages. As such, you will be able to apply what you learn about programming with Scratch 2.0 to other programming languages like Microsoft Visual Basic, Java, and C++.

WHAT YOU NEED TO BEGIN

As has been said, starting with Scratch 2.0, you no longer have to download and install Scratch. All you need is a web browser and a connection to the Internet in order to create, edit, and view Scratch 2.0 projects. So the first thing you must have is a relatively recent web browser. Any of the following web browsers is sufficient:

image Firefox 4 or later

image Chrome 7 or later

image Internet Explorer 7 or later

To work with Scratch 2.0, you also need Adobe Flash Player version 10.2 or later. If it is not already installed on your computer, you can download the most current version of Adobe Flash Player from http://get.adobe.com/flashplayer/. Lastly, Scratch 2.0 is designed to work on a computer screen that supports a resolution of 1024×768 or higher.

Tip


If you do not have easy access to the Internet, you can download and install a desktop-based version of Scratch 2.0, as explained in this book’s Appendix B, “Offline Scratch Development” (found on the companion website). If your computer and monitor do not support the required screen resolution, you also have the option of downloading and installing an older version of scratch (version 1.4), which supports a resolution of 800×480.


HOW THIS BOOK IS ORGANIZED

Scratch 2.0 Programming for Teens is organized into 14 chapters. This book was written with the expectation that you will read it sequentially, from cover to cover. However, if you have some previous programming experience, you may instead want to jump around a bit, focusing on topics that interest you the most.

The first four chapters introduce Scratch 2.0 and its development environment. You also learn about the different components that make up Scratch 2.0 projects and then discover how to create and execute Scratch 2.0 projects.

The next nine chapters are designed to provide instruction on how to work with different types of Scratch 2.0 code blocks. You learn how to use code blocks that move things around, store and retrieve data, and perform math and conditional and repetitive logic. In addition, you learn how to integrate sound and draw lines and shapes.

The last chapter helps bring together everything you have learned. This chapter introduces you to the concept of collision detection and teaches you how to use it as you learn the fundamentals of developing arcade-style computer games.

COMPANION WEBSITE DOWNLOADS

You can download the companion website files from www.cengageptr.com/downloads.

On the website, you’ll find four appendixes and a glossary. The first appendix provides you with insight and guidance on how to track down and fix programming errors that every programmer makes when developing applications. The second appendix explains how to download and install a desktop-based version of Scratch. This material is for readers who do not have Internet access but still want to learn how to program using Scratch. The third appendix demonstrates how to create Scratch 2.0 projects that interact with a sensor board. The fourth appendix provides a list of websites and reading materials that you will want to explore to continue learning more about Scratch 2.0 and to further your programming knowledge.

CONVENTIONS USED IN THIS BOOK

One of the primary objectives of this book is ease of reading and understanding. To help support this objective, some simple conventions have been used throughout this book to highlight critical information and emphasize specific points. These conventions are briefly described here.

Key terms that you want to understand and remember are highlighted using italic the first time they are instructed. So anytime you see a term in italic, take an extra moment to think about it and learn its meaning or purpose.

A monospace computer font is used to make things like commands, extensions, and filenames stand out from regular text.

Note


Notes provide additional information about a topic, feature, or idea to help you understand its impact or implications.


Tip


Tips point out programming shortcuts that make you a better and more efficient programmer.


Caution


Cautions identify areas where you are likely to run into problems and provide advice on how to deal with or prevent problems from occurring, making you a better, more efficient, and much happier programmer.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.140.185.147