Scratch
Scratch
Scratch
Welcome to the world of coding with Scratch! In this chapter, we'll lay the foundation for your
Scratch journey. We'll introduce you to Scratch's block-based coding system, guide you through
the process of creating a Scratch account, and take you on a tour of the Scratch interface.
Scratch is a beginner-friendly programming language that uses colorful blocks to build code.
Instead of typing lines of text, you'll snap together these blocks like puzzle pieces to create your
programs. This visual approach makes coding accessible and fun for everyone, regardless of age
or experience.
With Scratch, you'll be able to create animations, games, interactive stories, and more. By the
end of this tutorial, you'll have the skills to bring your ideas to life!
Before you start coding in Scratch, you'll need to create a Scratch account. Follow these steps to
get started:
1. Open your web browser and navigate to the Scratch website: https://scratch.mit.edu/.
2. Click on the "Join Scratch" button located in the upper-right corner of the page.
3. Fill in your username, password, and birthdate. Remember to choose a username that
you'll be comfortable with sharing in the Scratch community.
4. Complete the reCAPTCHA to verify that you're not a robot.
5. Optionally, you can provide an email address to recover your account if needed.
6. Review the Scratch Community Guidelines and the Scratch Privacy Policy, then click the
"Sign Up" button to create your account.
Congratulations, you now have a Scratch account! This account will allow you to save and share
your projects with others.
Let's take a quick tour of the Scratch interface so you know where to find everything:
1. Stage: This is where your projects come to life. Sprites will interact with each other on
this stage.
2. Sprites Pane: Here, you'll find all the sprites you add to your project. You can click on a
sprite to see and edit its scripts.
3. Blocks Palette: On the left side of the screen, you'll find different categories of coding
blocks. Drag and snap these blocks together to create your scripts.
4. Scripts Area: When you click on a sprite, its scripts will appear here. This is where you
assemble the blocks to make your sprite do what you want.
5. Costumes and Sounds: Each sprite can have multiple costumes (appearances) and
sounds. You can add, edit, and manage these in the respective tabs.
6. Green Flag: Clicking the green flag at the top of the stage starts your project. It's like
pressing play to see your code in action.
In this chapter, we'll explore the fascinating world of movement and animation in Scratch. You'll
learn how to make sprites move using arrow keys, create smooth animations for sprites, and even
put together a fun dance animation. Let's get started!
1. Select a Sprite: Choose a sprite that you want to control. It could be a character, a
vehicle, or anything else you'd like to move.
2. Add Event Block: In the sprite's scripts area, drag out an "When Green Flag Clicked"
block from the Events category. This block will start the script when the green flag is
clicked.
3. Control Movement: Add blocks from the Motion category to respond to arrow key
presses. Use "If" blocks along with "Key ___ Pressed?" blocks to detect arrow keys.
Combine these with "Change X by" and "Change Y by" blocks to move the sprite left,
right, up, and down.
4. Test the Movement: Click the green flag to test your sprite's movement. You should
now be able to control the sprite using the arrow keys on your keyboard.
Static sprites are cool, but animated sprites are even better! Let's learn how to create smooth
animations for your sprites:
1. Add Costumes: In the sprite's Costumes tab, click the "Costume" button to add
additional costumes. Each costume represents a different frame of the animation.
2. Use "Switch Costume" Block: In your sprite's script, use the "Switch Costume to ___"
block from the Looks category to change between costumes. Add "Wait" blocks to
control the timing of the animation.
3. Create a Looping Animation: To make an animation loop continuously, place your
costume-switching blocks inside a "Forever" loop block.
4. Run the Animation: Click the green flag to see your sprite come to life with the
animation you've created.
Sound effects are a fantastic way to enhance the interactivity and engagement of your Scratch
projects. In this chapter, we'll explore how to import sound, trigger sound effects based on
events, and even create a soundboard project that allows users to play different sounds. Let's dive
into the world of audio in Scratch!
Before you can add sound effects to your project, you'll need to import the sounds you want to
use. Here's how you can do it:
1. Find Sound Files: Locate sound files in formats like .mp3 or .wav that you'd like to
include in your project. These could be sounds of footsteps, doorbells, applause, and
more.
2. Import Sounds: In the Scratch interface, click on the "Sounds" tab of your sprite. Then,
click the "Choose a Sound from Library" button to select a sound from Scratch's library,
or click "Upload Sound" to import your own sound files.
3. Trim and Edit: After importing a sound, you can use the sound editor to trim or adjust
the sound's duration.
Now that you have sounds in your project, let's trigger them based on specific events:
1. Event-Based Sound: Drag out an event block such as "When Green Flag Clicked" or
"When [key] pressed" from the Events category.
2. Play Sound: From the Sound category, use the "Play Sound [sound]" block to play the
selected sound. You can place this block inside the event block.
3. Stop Sound: If needed, you can also use the "Stop All Sounds" block to halt any playing
sounds before playing a new one.
A soundboard project allows users to trigger different sounds by clicking on buttons. Let's build
one:
1. Design Buttons: Create sprites that represent buttons for each sound. These can be
simple shapes or icons.
2. Add Scripts: For each button sprite, add a script that responds to the "When [this sprite]
clicked" event.
3. Play Sound: Inside the button's script, use the "Play Sound [sound]" block to play the
corresponding sound when the button is clicked.
4. Customize Appearance: You can use costume-switching blocks to change the
appearance of the button when clicked, giving visual feedback to users.
5. Test the Soundboard: Click the green flag to test your soundboard project. Clicking on
different buttons should play different sounds.
Bring your storytelling skills to life in Scratch with interactive story scenes. In this chapter, we'll
guide you through creating captivating background scenes, adding characters as sprites, and
building interactive dialogues to engage your audience in your narratives.
A captivating background sets the stage for your story. Here's how you can create a background
scene:
1. Choose a Setting: Decide on the setting for your scene. It could be a forest, a city, a
castle, or any other location relevant to your story.
2. Import Background: Use the "Choose a Backdrop from Library" button in the Stage
area to select a suitable backdrop. You can also upload your own images.
3. Layering: If you want to add multiple backgrounds (e.g., changing scenes), use the
"Switch Backdrop to [backdrop]" block from the Looks category.
Characters are essential to any story. Let's add characters as sprites to your scene:
1. Select Characters: Choose sprites that represent the characters in your story. These
could be people, animals, or even objects with personalities.
2. Place Sprites: Drag and drop the sprite images onto the stage. You can resize, rotate, and
position them as needed.
3. Costumes: Customize your characters by adding different costumes to represent their
various actions or emotions.
An interactive dialogue engages users and lets them be a part of the story. Here's how to create
one:
1. Creating Dialogue Balloons: For each sprite that will participate in the dialogue, add a
speech balloon. You can use the "Say [text]" block from the Looks category to display
text.
2. Using Variables: If you want dynamic or changing text, use variables to store and
display different lines of dialogue.
3. User Interaction: Use event blocks like "When [sprite] clicked" to trigger dialogue.
When the sprite is clicked, show the corresponding speech bubble.
4. Multiple Options: For branching stories, use "If" blocks to provide different responses
based on the user's choices.
5. Timing and Animation: Combine dialogue with animations to create a richer
storytelling experience.
Remember, your interactive story can take any form you imagine. It could be a mystery, a
fantasy adventure, or a heartwarming tale. Let your creativity run wild!
Get ready to level up your Scratch skills by creating a simple but addictive game: Catch the
Falling Objects. In this chapter, you'll learn how to build a game from scratch, including creating
a catcher sprite, generating falling objects, and implementing scoring and game over mechanics.
The catcher sprite is the player-controlled character that will catch the falling objects:
1. Design the Catcher: Choose or design a sprite that will act as the catcher. This could be
a basket, a hand, or anything that suits your game theme.
2. Coding the Catcher: Add movement controls to the catcher sprite. Use arrow keys or
other controls to allow players to move the catcher left and right.
In this section, you'll learn how to make objects fall from the top of the screen that the player
needs to catch:
1. Design the Objects: Create sprites for the falling objects. These could be fruits,
raindrops, or any other items that fit your game's concept.
2. Random Position: Use the "Set X to [random position]" block to position the falling
objects randomly across the top of the screen.
3. Looping: Create a "Forever" loop to constantly generate new falling objects at random
positions.
4. Falling Motion: Use the "Change Y by" block to make the objects fall down the screen.
You can also add a "Wait" block to control the speed of the falling.
What's a game without a way to win or lose? Let's add scoring and a game over mechanic:
1. Adding Score: Create a variable to keep track of the player's score. Increment the score
whenever the player catches an object.
2. Displaying Score: Use the "Say [text]" block to display the current score on the screen.
3. Game Over Condition: Set a condition for when the player loses. For example, if an
object reaches the bottom of the screen without being caught.
4. Game Over Screen: When the game ends, you can display a game over message along
with the player's final score.
5. Restarting the Game: Provide an option for players to restart the game. This can be
triggered by clicking a button or pressing a key.
In this chapter, we'll delve into the exciting world of visual customization in Scratch. You'll learn
how to import images for costumes, make sprites change costumes dynamically, and even create
a dress-up game where users can mix and match different looks. Get ready to add a new layer of
creativity to your projects!
Customizing sprites with unique costumes can breathe life into your characters and objects:
1. Find Suitable Images: Search for or create images that match the costumes you want for
your sprite. These could be different outfits, expressions, or even transformations.
2. Importing Images: Click the "Costumes" tab of your sprite, then use the "Upload
Costume from File" button to import your images. You can also draw directly within
Scratch.
Animating your sprites through costume changes adds a dynamic touch to your projects:
1. Using the "Switch Costume" Block: In the sprite's scripts area, use the "Switch
Costume to [costume]" block from the Looks category.
2. Animating Costume Changes: Combine the "Switch Costume" block with "Wait"
blocks to create smooth transitions between costumes.
3. Control Through Events: Trigger costume changes based on events like user clicks or
keyboard inputs.
Now, let's apply what we've learned to create a dress-up game where players can customize a
sprite's appearance:
1. Choose a Sprite: Select a sprite that will serve as the character players can dress up. This
could be a person, an animal, or any creative character.
2. Import Outfits: Import a variety of costumes representing different outfits or
accessories.
3. Creating the Interface: Design buttons or controls that players can use to change the
sprite's costumes.
4. Changing Costumes: Create scripts for each button using "When [this sprite] clicked"
blocks. Use "Switch Costume to [costume]" to change the sprite's look.
5. Customize Further: To add complexity, consider letting players change the sprite's
color or size as well.
Costumes and looks offer endless possibilities for creativity. Try combining costume changes
with other actions to make characters blink, express emotions, or transform dramatically.
By mastering costume customization, you'll have the tools to create visually captivating projects
that engage your audience's imagination. In the next chapter, we'll explore animation techniques
that bring your sprites to life with movement and dynamic interactions.
In this chapter, we'll embark on an exciting journey to create a maze game in Scratch. You'll
learn how to design a maze background, move a sprite using keyboard controls, and set up
boundaries and a win condition to create a challenging and rewarding gaming experience.
1. Design the Maze: Plan and design a maze layout. It can be as simple or complex as you
like, with twists, turns, and dead-ends.
2. Draw or Import: You can use the Scratch drawing tools to create the maze or import an
image of the maze background.
Now, let's give the player control of a sprite that navigates through the maze:
1. Choose a Sprite: Select a sprite that will represent the player's character in the maze.
This could be a person, an animal, or any other figure.
2. Event-Based Movement: Use "When Green Flag Clicked" to start the script and listen
for keyboard inputs using "When [key] pressed" blocks from the Events category.
3. Moving the Sprite: Combine "If" conditions with "Change X by" and "Change Y by"
blocks to move the sprite according to the player's keyboard inputs.
A key aspect of a maze game is ensuring that the sprite can't move through walls and
establishing a win condition:
1. Setting Boundaries: In the sprite's movement script, use conditional checks to prevent
the sprite from moving through walls. If the sprite's path is blocked, it shouldn't move.
2. Winning the Game: Set up a win condition, like reaching a certain point in the maze.
This could be a specific location or even collecting an object.
3. Displaying Victory: When the player wins, use the "Say" block to display a victory
message.
4. Restarting the Game: Add an option to restart the game after victory or when the player
loses. This can be triggered by clicking a button.
By mastering the creation of a maze game, you'll have honed your skills in sprite control, event
handling, and creating interactive gameplay experiences. In the next chapter, we'll explore the
world of drawing and animation using the pen feature in Scratch. Get ready to bring your
projects to life with unique visual effects!
In this chapter, we'll explore the exciting world of drawing and visual creativity using the Pen
extension in Scratch. You'll learn how to draw shapes, patterns, and even create your own etch-a-
sketch project.
The Pen extension in Scratch allows you to draw lines and shapes directly on the stage. It's a
powerful tool for creating visual effects and interactive experiences.
1. Enabling the Pen: In the "Extensions" section, enable the "Pen" extension to access the
pen-related blocks.
Let's start by creating basic shapes and patterns using the pen:
1. Drawing Commands: Use blocks like "Pen Down," "Pen Up," "Pen Color," and "Pen
Size" to control the pen's behavior.
2. Drawing Lines: Combine "Pen Down" with "Move" blocks to draw lines.
3. Drawing Shapes: By repeating specific movements, you can draw shapes like squares,
triangles, and circles.
1. Sprite Controls: Designate arrow keys for controlling the sprite's movement.
2. Pen Controls: Use the pen blocks to draw lines as the sprite moves.
3. Shaking to Clear: Implement a feature where shaking the sprite clears the drawing.
In this chapter, we'll focus on animating your sprites and bringing them to life through
storytelling techniques. You'll learn how to make sprites talk with speech bubbles, combine
movement and speech, and craft a short animated story.
1. Creating Speech Bubbles: Design speech bubble sprites that will appear next to
characters.
2. Adding Text: Use the "Say [text]" block to make the sprite display dialogue in the
speech bubble.
Now, let's explore how to create dynamic conversations with moving sprites:
1. Coordinating Actions: Combine movement blocks with speech blocks to make sprites
move and talk simultaneously.
2. Character Interaction: Use multiple sprites to simulate interactions and conversations
between characters.
1. Designing Characters: Create sprites for characters and props that will appear in the
story.
2. Animating the Plot: Use costume changes, movement, and speech to create scenes and
interactions.
3. Adding a Plot: Craft a story with a beginning, middle, and end, using dialogues and
animation to convey the narrative.
By mastering animation and storytelling, you'll be able to create immersive and engaging
experiences that captivate your audience. In the next chapters, we'll dive into advanced concepts
such as broadcasts, cloning, and more.
In this chapter, we'll explore how to design and build an interactive quiz project in Scratch.
You'll learn how to create quiz questions, implement scoring and feedback mechanisms, and
build a fully interactive quiz experience.
10.1 Designing Quiz Questions and Answers
1. Choosing a Theme: Decide on the theme of your quiz. It could be general knowledge, a
specific topic, or even a fun personality quiz.
2. Crafting Questions: Create multiple-choice or true/false questions that match your
theme.
Let's make sure your quiz provides accurate scoring and feedback:
1. Scoring Mechanism: Assign points for correct answers and decide how to calculate the
final score.
2. Feedback: Use "Say" blocks to provide feedback on whether each answer was correct or
incorrect.
Now, let's put it all together and create an interactive quiz experience:
1. Question Display: Use sprites or text to display questions and answer choices.
2. User Interaction: Implement controls that allow users to select their answers.
3. Feedback and Scoring: Display feedback and calculate the score based on user
responses.
In this chapter, we'll dive into the world of platformer games, where you'll learn how to design
and create a character control system for a platformer-style game.
1. Designing the Level: Plan the layout of platforms, platforms, and obstacles in your level.
2. Background: Choose a suitable backdrop for your platformer level.
Now, let's give your character the ability to jump and move across platforms:
1. Character Controls: Use arrow keys to control the character's movement. Implement a
"jump" mechanism using the spacebar.
2. Gravity and Jumping: Add gravity to the character's movement to create realistic
jumping physics.
1. Creating Obstacles: Design and add obstacles like spikes, moving platforms, and
enemies.
2. Collision Detection: Implement collision detection to check if the character hits an
obstacle or platform.
3. Game Over and Winning: Set up conditions for game over (such as falling off the
screen) and winning (reaching a goal).
By mastering the mechanics of platformer games, you'll be able to create dynamic and thrilling
gameplay experiences. In the next chapters, we'll explore advanced concepts such as broadcasts,
cloning, and collaborative projects.