
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 keep moving diagonally.

Wow, the cat can move diagonally too!

That’s right.
By using the “point in direction” code,

you can move the cat in various directions.

Oh yeah,
we used the “point in direction 0” code when moving up and down.

Good memory!
Direction is important for sprites, right?
We’ll use this direction angle to move the cat diagonally.
Now, let’s have fun learning programming!
Here’s the Scratch Project We’ll Create Today!

Click the green flag to see the project!
What You’ll Learn in This Programming Lesson
1. You’ll understand the script that makes the cat move diagonally.

2.You’ll understand the script that makes the cat change direction when it hits the edge.

3. You’ll learn how to fix it when the cat turns upside down.

Let’s Look at the Script
Here’s the Sprite!


The sprite in this Scratch project is “Cat”.
On the Scratch screen, it shows “Cat”.
*We renamed “Sprite1” to “Cat”.
Here’s the Script!
Cat’s Script

Let’s Explain How to Program
Cat’s Script
Programming the Cat to Keep Walking Diagonally

Programming the Cat to Change Direction When It Hits the Edge

3 Ways to Fix the Upside-Down Sprite (Cat)


Huh?
The cat is always upside down when it moves to the left.

Look at the sprite’s (cat’s) direction!
It says “- (minus) ○ degrees,” right?
Remember, when the direction is “0 degrees,” it faces up.
So when the direction becomes negative, the sprite turns upside down!


By the way, when the sprite’s (cat’s) direction is “positive,”
it faces right as shown in the diagram below and doesn’t turn upside down!

3 Ways to Fix the Upside-Down Sprite (Cat)

- Click “left-right” in the direction section
- Add the “set rotation style left-right” code to the script
- Click “don’t rotate” in the direction section
1,Click “left-right” in the direction section


When you click “left-right” in the direction section, it fixes the upside-down problem and the cat faces left while moving left!
2, Add the “set rotation style left-right” code to the script

3, Click “don’t rotate” in the direction section


When you click “don’t rotate” in the direction section,
it fixes the upside-down problem and the cat moves left while facing right!
However, the sprite (cat) moves backward!!
That’s because it stays at 90 degrees without rotating!

Haha!
You’re right!
The cat is moving backward!!

When you’re programming and think “I want to fix the upside-down sprite,”
try these three methods!
Summary

Today, we learned programming to “move the cat diagonally.”
What We Learned in Today’s Programming

This time, we programmed to move the sprite diagonally using the “point in direction” code.

- Set the sprite’s direction
- “Point in direction 0” code – faces up
- “Point in direction 90” code – faces right
- “Point in direction 180” code – faces down
- “Point in direction -90” code – faces left


To make the cat move diagonally, we set the direction to 45 degrees!


Now, today’s programming
is complete!!
What Happens When You Change the Number in the “Move Steps” Code?

Let’s change the number in the “move 10 steps” code!
Try “40” or “211” or other numbers.
Enter your favorite number and see how the cat moves!


Hey, what happens if I use -10 steps?
Does the cat move backward?

Hehe… Well, what do you think will happen?
Let’s try it!
Something surprising will happen!

What? Tell me!

That’s a surprise for after you try it!

That’s all for today’s programming lesson!
We learned that you can set the sprite’s direction
using the “point in direction” code.

「〇度に向ける」コードでの スプライトの向き


We also learned how to fix it when the sprite (cat) turns upside down.
スプライト(ここではネコ)のを直す3つの方法

- Click “left-right” in the direction section
- Add the “set rotation style left-right” code to the script
- Click “don’t rotate” in the direction section

If your sprite turns upside down while programming,
try these methods!
See you again!!

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



コメント