
Hello!
I’m Teacher Ratch from “Scratch Fun Academy – Programming Classroom.”!

I’m Sukku. Nice to meet you!

Today, we’re going to program the cat to move left and right.

This cat’s movement can be made with just 5 code blocks!


Even a Scratch beginner like me can do this!
Let’s have fun learning programming together!
Today’s Scratch Project!

Check out the project!
What You’ll Learn Today
1. You’ll learn how to make the cat walk continuously.

2.You’ll learn how to make the cat turn around when it touches the edge.

3.You’ll learn how to keep the cat from flipping upside down when it changes direction.

Let’s Look at the Script
The Sprite for This Project!


The sprite for this Scratch project is “Cat”.
On the Scratch screen, it’s displayed as “Cat”.
* We changed “Sprite1” to “Cat”.
Here’s the Script!
Cat’s Script

Programming Instructions
Cat’s Script



What is the “Move Steps” Code?

What does the “move 10 steps” code do?

The “move ○ steps” code makes the sprite (the cat here) move.


10 steps doesn’t move very far!

That’s right. 10 steps is a small movement.
You decide how far the sprite (cat) moves with the number.
For example, if you change “10” to “100”, the cat will move much further!


I see!

However,
with just “move ○ steps”, the cat stops after moving that many steps!
we put it inside the “forever” block.

When you put it inside the “forever” block, the “move 10 steps” command repeats until you click the red stop button, so the cat keeps walking!


Hey, Teacher Ratch!
The cat went too far to the right, and I can only see its tail!

That’s right.
Since you haven’t clicked the red stop button,
the computer is still receiving commands, but the cat can’t move any further.
And here comes this code!
The “if on edge, bounce” code!
This code changes the sprite’s direction when it touches the edge of the stage!

When you put this code inside the forever block, when the cat touches the right edge, it changes direction and keeps walking to the left.
When it touches the left edge, it also changes direction and keeps walking to the right.
The cat will keep walking until you click the red stop button!

What is the “Set Rotation Style to Left-Right” Code?

Teacher Ratch!
The cat keeps walking, but it flips upside down!
This script doesn’t have the rotation code.


Yes!
That’s because when the cat touches the right edge,
it rotates 180 degrees clockwise and moves left!


And when it touches the left edge,
it also rotates 180 degrees clockwise and moves right!


So, we use this “set rotation style to left-right” code!

This code prevents the cat from rotating!
In other words, it tells the computer: “Make the cat face only right or left!”


Oh!
Now I understand!
Summary

Today, we learned programming to “move the cat left and right.”
What We Learned Today

We learned how to use 5 code blocks.
Let’s review them.
“When Green Flag Clicked” Code

When the green flag is clicked, the script below gives commands to the computer.

“Move ○ Steps” Code

Moves the sprite. The number shows how far the sprite moves.

“Forever” Block

Repeats the code inside until you click the red stop button.

“If on Edge, Bounce” Code

When the sprite touches the edge, it changes direction.


“Set Rotation Style to Left-Right” Code

〇Sets the sprite’s direction to only right or left.


In today’s programming, we made the cat move left and right continuously.
To do this:
1,Move the sprite (cat)

2,Keep moving the sprite

3,When it touches the edge, change the sprite’s direction

4,Fix the cat from flipping upside down

If you think this way, you can create today’s project!

Yay!
Today’s programming is complete!
Try This!

Try changing the number in the “move 10 steps” code!
Try “40” or “123”…
Enter your favorite number and see how the cat moves!


Hey, Teacher Ratch!
What if I enter “-100”? What will happen to the cat?

Oh! That’s interesting!
Try entering “-100” right away!
It’s fun to imagine what will happen before you try it!
See if your guess is correct.
Programming is exciting when you test your ideas!

That’s all for today’s programming lesson!
Did you understand how to move the cat?
As you continue creating projects in Scratch, you’ll learn more about codes and blocks, and understand programming better.
Let’s make lots of projects!
See you next time!

See you!
(@^^)/~~~



コメント