How to Make a Catch Game in Scratch | Tutorial

Scratch Team
26 Jan 202106:34

Summary

TLDRZoë from the Scratch team introduces a tutorial on creating a catch game in Scratch, guiding viewers through five steps: moving the catcher, making objects fall, catching them, and keeping score. She demonstrates using a bowl and apple, detailing the setup for movement with arrow keys, object spawning at the top, continuous falling and resetting, and scoring with a variable. The tutorial is designed to inspire creativity with customizable objects, characters, and backdrops.

Takeaways

  • 🎮 The video is a tutorial on creating a catch game in Scratch, where objects fall and are caught to score points.
  • 👩‍💻 Zoë from the Scratch team guides viewers through the game development process, breaking it down into five main steps.
  • 🕹️ The first step involves selecting a character or object to act as the catcher and enabling its movement with arrow keys.
  • 🔄 The 'if then' block is crucial for responding to key presses, allowing the catcher to move left and right on the screen.
  • 🔁 A 'forever loop' is used to continuously check for key presses, ensuring the catcher can move throughout the game.
  • 🍎 The second step is choosing an object to fall, such as an apple, and programming it to start at a random position at the top of the screen.
  • 📉 The falling motion is achieved by changing the Y position in a negative direction within a 'forever loop' to simulate gravity.
  • 🔄 The apple should return to the top of the screen if it reaches the bottom, which is checked using an 'if then' block with a condition based on the Y position.
  • 🤲 The game includes a mechanism to detect when the falling object touches the catcher, using a 'touching' block to trigger a catch.
  • 🎵 A sound effect is played when the apple is caught, enhancing the game's interactivity and feedback to the player.
  • 🏆 A scoring system is implemented using a variable to keep track of the player's points, which increases upon catching the falling object.
  • 🌐 The video concludes with encouragement for viewers to create their own variations of the catch game, suggesting themes like environmental cleanup or pet treats.

Q & A

  • What is the main topic of the video script?

    -The main topic of the video script is how to create a catch game in Scratch, where objects fall from the sky and are caught to score points.

  • Who is the presenter of the video?

    -The presenter of the video is Zoë from the Scratch team, also known as Zinnea.

  • What are the five steps to create the catch game as mentioned in the script?

    -The five steps are: 1) Move the catcher, 2) Make the object go to the top, 3) Make the object fall down, 4) Catch the object, and 5) Keep score.

  • Which Scratch block is used to make the catcher move with the arrow keys?

    -The 'change X by 10' block is used in conjunction with an 'if then' block to make the catcher move with the arrow keys.

  • What is the purpose of the 'if then' block in Scratch?

    -The 'if then' block is used to execute code only if a certain condition is true, such as checking if a key is pressed.

  • How does the script suggest to make the falling object start at a random position at the top of the screen?

    -By using the 'go to random position' block and setting the Y position to 180, the object starts at a random place at the top of the screen.

  • What does the Y position in Scratch represent?

    -In Scratch, the Y position represents how far a sprite is from the bottom of the screen to the top.

  • How can the falling object be made to return to the top after reaching the bottom?

    -By using an 'if then' block to check if the Y position of the object is less than -170, and if so, resetting its position to a random place at the top.

  • What block is used to detect if the falling object touches the catcher?

    -The 'touching' block is used to detect if the falling object is touching the catcher, with the option to specify the catcher as 'bowl'.

  • How is the score kept and updated in the game?

    -A variable called 'Score' is used to keep track of the points. The 'change score by 1' block is used to increase the score each time an apple is caught.

  • What additional feature does the script suggest to enhance the game?

    -The script suggests adding a sound effect when an apple is caught to enhance the game experience.

  • What does Zoë encourage the viewers to do at the end of the video?

    -Zoë encourages the viewers to create their own variations of the catch game, using different objects, catchers, and backdrops.

Outlines

00:00

🕹️ Creating a Catch Game in Scratch

Zoë from the Scratch team introduces a tutorial on creating a catch game in Scratch. The game involves objects falling from the sky and a character or object catching them to score points. The tutorial is divided into five steps: moving the catcher, making objects go to the top, falling down, catching them, and keeping score. The first step is to choose a catcher, in this case, a bowl, and make it move with arrow keys using 'change X by 10' blocks within an 'if then' structure inside a 'forever' loop. The tutorial also covers adding a backdrop and using the 'if then' block to check for key presses continuously.

05:00

🍎 Making Objects Fall and Reset

The second part of the tutorial focuses on selecting an object to fall, such as an apple, and making it start at a random position at the top of the screen using 'go to random position' and 'set Y' blocks. The apple is programmed to fall by changing its Y position by -10 in a 'forever' loop. An 'if then' block checks if the apple reaches the bottom of the screen (Y position less than -170) and, if so, resets its position to the top. This creates a continuous falling and resetting mechanism for the object.

Mindmap

Keywords

💡Scratch

Scratch is a block-based visual programming language and online community targeted primarily at children. It allows users to create their own interactive stories, games, and animations. In the video's context, Scratch is used to demonstrate how to create a 'catch game,' where users can program objects to fall and be caught by a character, which is a fundamental concept in game design.

💡Sprite

In Scratch, a sprite refers to an object or character that can be programmed to perform actions. It can be a graphic, a character, or any other visual element that can move or interact within the Scratch stage. The video uses the terms 'character' and 'object' interchangeably with 'sprite,' as they are the primary elements in creating the catch game, with one sprite catching the falling sprites.

💡Backdrop

A backdrop in Scratch is a static or animated background that provides the setting for the sprites in a project. The video mentions adding a backdrop, such as 'boardwalk,' to set the scene for the game, enhancing the visual appeal and providing context for the game's setting.

💡If-then block

An 'if-then' block in Scratch is a control structure that allows for conditional execution of code. If the condition specified in the 'if' block is true, then the code within the 'then' block will execute. The video explains how to use 'if-then' blocks to control the movement of the catcher sprite with arrow keys and to check if the falling object has reached the bottom of the screen.

💡Forever loop

A forever loop in Scratch is a control structure that repeats the code inside it indefinitely. It is symbolized by an infinity symbol and is used to create continuous actions such as making a sprite move or checking for conditions over and over. In the video, a forever loop is used to keep checking if the arrow keys are pressed to move the catcher and to make the falling object continuously fall.

💡X and Y coordinates

In Scratch, the X and Y coordinates determine the position of a sprite on the screen. The X coordinate represents the horizontal position, while the Y coordinate represents the vertical position. The video uses the concept of changing the X coordinate by a certain value to move the catcher sprite left or right, which is essential for catching the falling objects.

💡Random position

In Scratch, placing a sprite at a 'random position' means setting the sprite's coordinates to a random location within the defined boundaries. The video uses this concept to start the falling object at a random position at the top of the screen, adding an element of unpredictability to the game.

💡Touching

In Scratch, 'touching' refers to the condition when two sprites are in contact with each other. The video uses this concept to detect when the falling object 'touches' or is caught by the catcher sprite, triggering the object to stop falling and return to the top of the screen.

💡Variable

A variable in Scratch is a container for storing values that can change during the program's execution. The video introduces a variable called 'Score' to keep track of the player's score, increasing it by one each time an apple is caught. Variables are fundamental in games for keeping scores and tracking game progress.

💡Game mechanics

Game mechanics refer to the rules, challenges, and interactions that define how a game works. The video outlines the basic mechanics of a catch game, including moving a catcher sprite, making objects fall, detecting catches, and keeping score. Understanding game mechanics is crucial for creating engaging and functional games.

Highlights

Introduction to creating a catch game in Scratch by Zoë from the Scratch team.

Five steps to build the game: move the catcher, make the object fall, catch it, and keep score.

Choosing a character or object to act as the catcher in the game.

Using the arrow keys to control the catcher's movement.

Explanation of how to use 'if then' blocks for conditional actions in Scratch.

Implementing a forever loop to continuously check for arrow key presses.

Selecting an object to fall from the sky and making it start at a random position at the top of the screen.

Using the 'go to random position' and 'set Y' blocks to position the falling object.

Creating a falling motion for the object with a forever loop and negative Y changes.

Adding an if then block to check if the falling object has reached the bottom of the screen.

Coding the object to return to the top when it reaches the bottom.

Setting up a condition to detect when the falling object touches the catcher.

Using the 'touching' block to create a catching mechanism in the game.

Adding a sound effect to enhance the catching experience.

Introducing variables to keep track of the game score.

Increasing the score by one each time an object is caught.

Resetting the score to zero at the start of the game.

Encouragement to create diverse catch games with different themes and objects.

Closing remarks and sign-off with 'Scratch on'.

Transcripts

play00:00

- Hi everyone, it's Zoë from the Scratch team,

play00:02

also known as Zinnea.

play00:03

Today I wanted to show you

play00:05

how to make a catch game in Scratch.

play00:07

A game where objects are falling from the sky

play00:09

and you catch them to score points.

play00:10

It could be any object that's falling,

play00:12

and it can be any character or object that's catching it.

play00:14

We'll break this into five steps.

play00:16

Move the catcher, make your object go to the top,

play00:20

fall down, catch it, and keep score.

play00:25

Let's get started.

play00:26

First, let's pick the character or object

play00:28

that you want to be catching things,

play00:30

and we're gonna make it move with the arrow keys.

play00:32

You can just click this button that says, Choose a Sprite,

play00:34

and you can pick anything you want.

play00:36

I'll use the bowl, and let's add a backdrop too.

play00:39

I'll use the boardwalk.

play00:41

So, we want the bowl to be able to move side to side

play00:44

with the arrow keys, so that it can catch

play00:46

whatever's gOnna be falling.

play00:47

We can use this block, change X by 10

play00:49

to make the ball go this way.

play00:51

Let's make the ball do this,

play00:53

if the right arrow key is pressed.

play00:55

There's a really helpful block for this,

play00:57

which is an if then block.

play00:58

In case you haven't seen an if then block before,

play01:00

here's how they work.

play01:01

I find that they're really easy to use.

play01:03

If then blocks will make a Sprite

play01:05

do the code that's in here,

play01:07

only if the thing that's in here is true.

play01:11

So in this example,

play01:12

if the cat is touching the mouse pointer

play01:14

it will play the sound, meow,

play01:16

but if it's not touching the mouse pointer,

play01:18

it won't play any sound.

play01:19

So in our game, if the right arrow key is pressed,

play01:24

we can make the bowl change X by 10.

play01:26

Let's try it out, and let's make it start

play01:28

when I click the green flag.

play01:30

So, I'm pressing the right arrow key

play01:32

but nothing is happening.

play01:34

That's because this if then block

play01:36

is only being checked once.

play01:37

When I click the green flag,

play01:39

it's asking, is the right arrow being pressed right now?

play01:42

But then it just stops doing the code.

play01:43

And what we want it to do, is always be checking

play01:47

if the right arrow key is pressed at any moment.

play01:49

So, we can just put this inside a forever loop.

play01:52

And now, now this is what we want.

play01:55

It's always checking, is the right arrow key being pressed?

play01:58

And to make the bowl go to the left,

play01:59

instead of changing X by 10, we can change X by -10.

play02:04

Let's make it do this, if the left arrow key is pressed.

play02:07

And let's put this in the forever loop too.

play02:10

There we go, now we have a catcher

play02:12

that we can move with the arrow keys.

play02:14

Next, let's pick the object that we want to be falling

play02:16

and make it go to the top of the screen.

play02:18

You can use any object you want.

play02:20

I'll use the apple.

play02:22

At the beginning of the game,

play02:23

We want the apple to start at a random place at the top.

play02:27

This block, go to random position,

play02:29

will make it go to a random place.

play02:31

And this block, set Y, can set how high up a Sprite is.

play02:36

In Scratch, Y represents how far a Sprite is

play02:39

from the bottom of the screen to the top of the screen.

play02:41

So if we set Y to zero,

play02:43

the apple goes up to about the middle.

play02:45

If we set Y at 20, it goes up a little higher,

play02:47

and 180 makes it go all the way to the top.

play02:50

Now, if we make the apple go to a random position

play02:52

and then set Y to 180, it goes to a random place

play02:55

but then Y is always set to be at the top,

play02:58

And that's just what we want.

play02:59

When the game starts,

play03:00

it starts at a random place at the top of the screen.

play03:02

Now, let's make our apple fall down.

play03:04

If we change, Y by 10, the apple goes upwards.

play03:08

To make it go down, we can put in a negative number.

play03:11

And if we put this inside a forever loop,

play03:13

it'll keep falling until it hits the bottom.

play03:15

But now it's stuck.

play03:16

So right now, we have an apple that can fall one time,

play03:19

what we would like it to do

play03:20

is if it's at the bottom, it goes to the top.

play03:23

This is another good time to use an if then block.

play03:25

So let's drag one out.

play03:27

In here, we need to put some code

play03:29

that checks if the apple is at the bottom.

play03:31

Now, how can we tell if the apple is at the bottom?

play03:34

Well, remember how I said

play03:35

that Y represents how high up a Sprite is,

play03:38

let's look at the apple's Y while it's falling.

play03:40

Its Y position starts at 180,

play03:43

then it goes to 170, 160, it gets to zero,

play03:46

then it goes to -10, -20.

play03:48

And then down here, it's like -170.

play03:50

So what we can test in here is,

play03:52

we can just check if the Y position of the apple

play03:54

is less than -170.

play03:56

'Cause if the apple's Y position is that low,

play03:59

then we know it must be at the bottom.

play04:01

So to test that, we can drag out this round blue block

play04:04

that says Y position, and drag out the green less than block

play04:08

from the operator's category.

play04:10

This block just checks if the thing on this side

play04:13

is less than the thing on this side.

play04:14

We want to check if Y is less than -170.

play04:17

So we can put Y on this side, and write -170.

play04:21

Now, if the apple is at the bottom,

play04:23

what do we want it to do?

play04:24

Well, we want it to go back up to the top,

play04:26

and we actually already have the code for that

play04:28

because we wrote it right here.

play04:29

So, let's just put a copy of that same code in here.

play04:32

And let's put this code inside our forever loop.

play04:35

So every time the apple moves down by -5,

play04:38

it asks, am I at the bottom?

play04:40

There we go.

play04:41

Now we have an apple that can fall,

play04:42

and when it gets to the bottom, it goes back up to the top.

play04:44

Now, let's make it so that we can actually catch the apples

play04:47

instead of them just falling through the bowl.

play04:49

If the apple touches the bowl, then the player caught it.

play04:52

So it should stop falling

play04:54

and go back to the top somewhere else

play04:56

so it can start falling again.

play04:57

So, this is another good time for an if then block.

play05:00

There's this helpful block that says,

play05:01

touching mouse-pointer,

play05:02

and instead of mouse-pointer, I can choose bowl.

play05:06

And now this block will test

play05:07

if the apple is touching the bowl.

play05:09

And if the apple is touching the bowl,

play05:11

we want it to go back to the top.

play05:13

And again, that's just our same code from before

play05:15

that makes it go to the top.

play05:17

Let's put this inside a forever loop,

play05:20

and let's make it play a sound when we catch it.

play05:22

Nice. Lastly, let's add a score

play05:25

so that you get points for every apple you catch.

play05:28

To make a score, We can add a variable.

play05:31

If you haven't seen this before,

play05:32

a variable lets you keep track

play05:34

of a certain number in your project.

play05:36

So, we can make a variable called Score

play05:39

and use it to keep track of how many points we've scored.

play05:42

We can use this change score by one block

play05:44

to make the score increase,

play05:46

and we can put this block here

play05:48

so every time we catch the apple,

play05:50

the score increases by one.

play05:52

And when the game starts, let's set the score to zero.

play05:56

So it resets, there we go.

play05:58

That's a catch game.

play05:59

Anyway, that's basically what I wanted to show you today.

play06:02

I love catch games 'cause I feel like they can be

play06:04

any type of game based on the objects that are falling

play06:07

and the character or the object that's catching them,

play06:09

and the backdrop you choose.

play06:11

You could be catching pieces of trash

play06:12

to keep an ocean clean,

play06:14

or a pet could be catching treats, or just really anything.

play06:18

I'm so excited to see all the things you make.

play06:20

Well, I'll see you next time, and Scratch on.

play06:23

(upbeat music)

Rate This

5.0 / 5 (0 votes)

関連タグ
Scratch TutorialGame DevelopmentCatch GameCoding BasicsInteractive DesignEducational ToolObject MovementScore TrackingGame MechanicsScratch Coding
英語で要約が必要ですか?