Book Image

Scratch 2.0 Beginner's Guide: Second Edition

By : Michael Badger
Book Image

Scratch 2.0 Beginner's Guide: Second Edition

By: Michael Badger

Overview of this book

Table of Contents (18 chapters)
Scratch 2.0 Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – creating a color palette


How do we know that a color value of 15 will get us orange? Let's create a simple app for that. We know that we have 200 color values, so let's script a program to draw each color value for a specified shade.

For this exercise, I'd recommend that you build the script for the color picker sprite we added in the previous exercise, and then you could add the sprite to your backpack and have both the picker and the script in one place. Let's run through this exercise, and then we'll discuss some variations. If you completed the Breakout game, then the logic for creating the color swatches in the following exercise will look familiar:

  1. Since we will be repeating a pattern a set number of times, create a new variable called count.

  2. Create a custom block named draw colors.

  3. Let's set the starting values for our script by attaching the following blocks to the define draw colors block:

    • clear

    • go to x: (-240) y: (180)

    • set (count) to (0)

    • set pen size to (18)

    • set...