How to Make Cat Move Randomly in Scratch

Motion
ラッチ先生
ラッチ先生

Hello!

I’m Teacher Ratch from “Let’s Scratch! Fun Programming Classroom.”

スック
スック

I’m Sukku.

Nice to meet you!

ラッチ先生
ラッチ先生

Sukku.

Look at how the cat moves!
It’s such an interesting movement, isn’t it?

scratch ネコが勝手に動く
スプライトが勝手かってうご
「○秒でどこかの場所へ行く」ブロック
ネコをいろんなところにうごかす
スック
スック

It moves like a ghost in a game!

ラッチ先生
ラッチ先生

That’s right! It moves like a ghost!

In Scratch, you can program this movement with just 3 blocks!

スック
スック

What? Just 3 blocks!

ラッチ先生
ラッチ先生

Yes!

This is the script that makes the cat move like a ghost!

scratch ネコが勝手に動くスクリプト
スプライトが勝手かってうごスクリプト
スック
スック

Oh, you just need this “glide to random position” block!

ラッチ先生
ラッチ先生

That’s right. It’s easy, isn’t it? You can make various games with this block.

Let’s create it together!

スック
スック

Okay!

Now, let’s have fun learning programming!

スポンサーリンク

Today’s Scratch Project!

  • Click the green flag. The cat moves to a random place in 1 second.
  • Click the cat. It says “Hello!” and stops.
スック
スック

Watch how the cat moves!

What You’ll Learn Today

1. You’ll learn the script that makes the cat keep moving to random positions in 1 second.

「スクラッチしよう!1-6 ネコをいろんな所に動かそう!」 scratchのネコが1秒でどこかへ動く
ネコが1びょうかけてどこかへうご

2. You’ll learn the script that makes the cat say “Hello!” and stop when clicked.

「スクラッチしよう!1-6 ネコをいろんな所に動かそう!」 scratchのネコをクリックすると「こんにちは!」と言う
ネコをクリックすると しゃべる
スポンサーリンク

Let’s Look at the Script

The Sprite

「スクラッチしよう!1-6 ネコをいろんな所に動かそう!」 スクリプト
スプライト
ラッチ先生<br>
ラッチ先生

The sprite in this Scratch project is:

  • “Cat”
  • We changed the name from “Sprite1” to “Cat.”

The Script

Cat’s Script

「スクラッチしよう!1-6 ネコをいろんな所に動かそう!」scratch ネコのスクリプト
ネコのスクリプト

Programming Explanation

Cat’s Script

Programming to Make the Cat Move Somewhere in 1 Second

「スクラッチしよう!1-6 ネコをいろんな所に動かそう!」scratch ネコが1秒かけてどこかへ動くスクリプト
ネコが1びょうかけてどこかへくスクリプト
「1秒でどこかの場所へ行く」ブロック
scratch 「1秒でどこかの場所へ行く」ブロック
「1びょうでどこかの場所ばしょく」ブロック
  • The computer makes the sprite (in this case, the cat) glide to a random position in 1 second
scratch 「1秒でどこかの場所へ行く」ブロックの役目
「1びょうでどこかの場所ばしょく」ブロックの役目やくめ

Programming to Stop Movement When Cat is Clicked

「スクラッチしよう!1-6 ネコをいろんな所に動かそう!」scratch ネコをクリックすると動きが止まるスクリプト
ネコをクリックすると まるスクリプト
「このスプライトが押されたとき」ブロック
「このスプライトが押されたとき」ブロック
「このスプライトがされたとき」ブロック
  • When the sprite is clicked, the script below gives commands to the computer.
scratch 「このスプライトが押されたとき」ブロックの役目
「このスプライトがされたとき」ブロックの役目やくめ
スック
スック

The “stop other scripts in sprite” code stops the other scripts from running.

For more details, please read this article.

Programming to Make the Cat Talk and Finish

「スクラッチしよう!1-6 ネコをいろんな所に動かそう!」scratch ネコが「こんにちは!」と言って終わるスクリプト
ネコがしゃべってわるスクリプト
スポンサーリンク

What’s the Difference Between “go to random position” and “glide to random position”?

スック
スック

Teacher Ratch,

「1びょうでどこかの場所ばしょく」コード
「どこかの場所ばしょく」コード

What’s the difference between these two codes?

ラッチ先生
ラッチ先生

The “glide 1 secs to random position” codemakes the sprite (in this case, the cat) move somewhere over 1 second.

The “go to random position” codemakes the sprite (in this case, the cat) appear somewhere instantly.

「1秒でどこかの場所へ行く」と「どこかの場所へ行く」ブロックのちがい
  • The “glide 1 secs to random position” code
scratch 「1秒でどこかの場所へ行く」ブロックの役目
「1びょうでどこかの場所ばしょく」コードの役目やくめ
  • The “go to random position” code
scratch 「どこかの場所へ行く」ブロックの役目
「どこかの場所ばしょく」コードの役目やくめ
スック
スック

I see!

I got it!

スポンサーリンク

Summary

ラッチ先生
ラッチ先生

Today,

we learned programming to make the cat move randomly using the “glide 1 secs to random position” block.

What We Learned Today

ラッチ先生
ラッチ先生

Here’s the programming to make the cat move randomly!

「スクラッチしよう!1-6 ネコをいろんな所に動かそう!」scratch  ネコが勝手に動くスクリプト
スック
スック

If you change the time,

the cat’s movement becomes even more interesting!

ラッチ先生
ラッチ先生

That’s right.

This script can be used for enemy or target movements in shooting games.

I hope everyone will use it in their projects.

See you later!!

スック
スック

See you!

(@^^)/~~~

コメント