How to Move Cat Diagonally in Scratch

Motion
ラッチ先生
ラッチ先生

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,

scratch 「〇度に向ける」コード
「〇ける」コード

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 and the cat moves diagonally!
  • The cat changes direction when it hits the edge!
  • Click the red button and the cat stops!
スック
スック

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.

「スクラッチしよう!1-3 ネコをななめに動かそう!」scratch ネコがななめに歩きつづける
ななめにあるきつづける

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

「スクラッチしよう!1-3 ネコをななめに動かそう!」scratch ネコが端に当たると向きを変える
はしたると、きをえる

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

「スクラッチしよう!1-3 ネコをななめに動かそう!」scratch ネコが逆さまになったら なおす
ネコの姿すがたさかさを なおす
スポンサーリンク

Let’s Look at the Script

Here’s the Sprite!

「スクラッチしよう!1-3 ネコをななめに動かそう!」scratch スプライト
スプライト
ラッチ先生<br>
ラッチ先生

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

「スクラッチしよう!1-3 ネコをななめに動かそう!」scratch ネコのスクリプト
ネコのスクリプト

Let’s Explain How to Program

Cat’s Script

Programming the Cat to Keep Walking Diagonally

「スクラッチしよう!1-3 ネコをななめに動かそう!」scratch ネコがななめに歩きつづけるスクリプト
ななめにあるつづけるスクリプト

Programming the Cat to Change Direction When It Hits the Edge

「スクラッチしよう!1-3 ネコをななめに動かそう!」scratch ネコが端に当たると向きを変えるスクリプト
はしたるときをえるスクリプト
スポンサーリンク

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

scratch 「向き」の「自由に回転」
ネコの姿すがたさかさをなお1
スック
スック

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!

sprite’s direction(-)
scratch スプライトの向き マイナス
スプライトの-(マイナス)
ラッチ先生
ラッチ先生

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!

sprite’s direction(+)
scratch スプライトの向き プラス
スプライトのき+(プラス

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

Ways to Fix the Upside-Down Sprite
scratch スプライトの逆さまを直す
ネコの姿すがたさかさを なお
  1. Click “left-right” in the direction section
  2. Add the “set rotation style left-right” code to the script
  3. Click “don’t rotate” in the direction section

1,Click “left-right” in the direction section

scratch 「向き」の「左右のみ」をクリックする
ネコのさをなおす 「左右さゆうのみ」をクリック
ラッチ先生
ラッチ先生

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

scratch 「回転方法を左右のみにする」コードをコードの挿入する
ネコのさかさをなおす 「回転方法かいてんほうほう左右さゆうのみにする」コード

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

scratch 「向き」の「回転しない」をクリックする
ネコのさかさをなおす 「回転かいてんしない」クリック
ラッチ先生
ラッチ先生

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.

“Point in direction 0” code
scratch 「〇度に向ける」コード
「〇ける」コード
  • Set the sprite’s direction
  1. “Point in direction 0” codefaces up
  2. “Point in direction 90” codefaces right
  3. “Point in direction 180” codefaces down
  4. “Point in direction -90” codefaces left
scratch 「〇度に向ける」コードの役目
「〇ける」コードの使つかかた
ラッチ先生
ラッチ先生

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

scratch ネコがななめに歩きつづけるスクリプト
ネコをななめにあるつづけるスクリプト
スック
スック

Now, today’s programming

is complete!!

スポンサーリンク

What Happens When You Change the Number in the “Move Steps” Code?

ラッチ先生<br>
ラッチ先生

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!

「スクラッチしよう!1-3 ネコをななめに動かそう!」scratch ネコのスクリプト 「〇歩動かす」の数字を変える
「○うごかす」コードの数字すうじえる
スック
スック

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!

スック<br>
スック

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.

scratch 「〇度に向ける」コード
「〇ける」コード

「〇ける」コードでの スプライトの

scratch 「〇度に向ける」コードの役目
「〇ける」コードの使つかかた
ラッチ先生
ラッチ先生

We also learned how to fix it when the sprite (cat) turns upside down.

スプライト(ここではネコ)のさかさまなおす3つの方法ほうほう

scratch スプライトの逆さを直す
スプライトのさかさをなお
  1. Click “left-right” in the direction section
  2. Add the “set rotation style left-right” code to the script
  3. 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!

(@^^)/~~~

コメント