How to Teleport Cat in Scratch

Motion
ラッチ先生
ラッチ先生

Hello!

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

スック
スック

I’m Sukku.

Nice to meet you!

ラッチ先生
ラッチ先生

Sukku.

Have you ever played games where ghosts or enemies appear and disappear in different places like this?

scratch スプライトがいろんな所に現れる
スプライトがいろんなところ表示ひょうじされる
スック
スック

Yeah!

You often see that in shooting games!

ラッチ先生
ラッチ先生

You can make the cat appear in different places with just 4 code blocks!

スック
スック

What!

Just 4 code blocks!

ラッチ先生
ラッチ先生

Here’s the script to make the cat appear in different places.

「スクラッチしよう!1-5 ネコを瞬間移動させよう!」scatch ネコがいろんな所に出現させるスクリプト
スプライトがいろんなところ出現しゅつげんさせるスクリプト
スック
スック

I can do this too!

ラッチ先生
ラッチ先生

If you learn this programming, you can make games too!

Let’s try it right away!

スック
スック

Let’s do it!

Now, let’s learn programming in a fun way!


スポンサーリンク

Here’s the Scratch project we’re making today!

  • Click the green flag: the cat teleports around
  • Click the cat: it says “Hello!” and stops
スック
スック

Try clicking the cat!

What you’ll learn in this programming lesson

1. You’ll understand the script that makes the cat appear in different places.

「スクラッチしよう!1-5 ネコを瞬間移動させよう!」scratch ネコをいろんな所に出現する
ネコがいろんなところあらわれる

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

「スクラッチしよう!1-5 ネコを瞬間移動させよう!」scratch ネコをクリックすると「こんにちは!」と言う
ネコをクリックするとしゃべる
スポンサーリンク

Let’s look at the script

Here’s the sprite!

「スクラッチしよう!1-5 ネコを瞬間移動させよう!」スプライト
スプライト
ラッチ先生<br>
ラッチ先生

The sprite in this Scratch project is:

  • “Cat”
  • I renamed “Sprite1” to “Cat.”

Here’s the script!

Cat’s Script

「スクラッチしよう!1-5 ネコを瞬間移動させよう!」scratch ネコのスクリプト
ネコのスクリプト

Let me explain how to program this

Cat’s Script

Programming to make the cat appear in different places

「スクラッチしよう!1-5 ネコを瞬間移動させよう!」scratch ネコが1秒ごといろんな所に現れる
ネコがいろんなところあらわれるスクリプト
“Go to random position” code
scratch 「どこかの場所へ行く」コード
「どこかの場所ばしょく」コード
  • The computer randomly decides where to display the sprite.
scratch 「どこかの場所へ行く」コードの役目
「どこかの場所ばしょく」コードの役目やくめ

Programming to stop when the cat is clicked

「スクラッチしよう!1-5 ネコを瞬間移動させよう!」scratch ネコをクリックすると止まるスクリプト
クリックするとネコがまる
“when this sprite clicked” block
scatch 「緑の旗を押されたとき」ブロック
「このスプライトがされたとき」ブロック
  • When the sprite is clicked, the script below gives commands to the computer.
「このスプライトがされたとき」ブロックの役目やくめ
スック
スック

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

Read this article for more details.

Programming to make the cat speak and finish

「スクラッチしよう!1-5 ネコを瞬間移動させよう!」scratch ネコが「こんにちは!」と言って終わるスクリプト
ネコがしゃべってわる
スポンサーリンク

How do I change the teleport timing?

スック
スック

Teacher Ratch,
the cat’s teleportation is too slow and I can click it easily!
Can it teleport faster?

ラッチ先生
ラッチ先生

That’s right!

If you make the cat teleport faster, it becomes harder to click and more fun!

Then let’s change the “wait 1 seconds” code to “wait 0.5 seconds” by entering “0.5”!

「スクラッチしよう!1-5 ネコを瞬間移動させよう!」scratch ネコ 「1秒待つ」を「0.5秒待つ」に変更
「0.5びょうつ」コードのする
スック
スック

Wow! Now I can’t click the cat easily!

Yeah, it’s getting more fun!

ラッチ先生
ラッチ先生

Try changing the number in the “wait _ seconds” code to make different cat movements and make it more fun!

スック
スック

Hey, what happens to the cat’s movement if I set it to “wait -1 seconds”?

「スクラッチしよう!1-5 ネコを瞬間移動させよう!」scratch ネコ 「1秒待つ」を「-1秒待つ」に変更
「-1びょうつ」コードにする
ラッチ先生
ラッチ先生

Hehe…

That’s interesting!

I wonder what “wait -1 seconds” means…

Try it yourself!

スック
スック

Huh…?

・・・

ラッチ先生
ラッチ先生

Stop! That’s enough!

Sukku, be quiet!

You who are reading this should try it yourself to see what happens!

You’ll definitely go “Huh…?!!”

スポンサーリンク

Summary

ラッチ先生
ラッチ先生

Today,
we learned programming to teleport the cat using the “go to random position” code.

What we learned today

ラッチ先生
ラッチ先生

Programming to make sprites appear in different places uses these 4 code blocks.

「スクラッチしよう!1-5 ネコを瞬間移動させよう!」scratch ネコがいろんな所に出現するスクリプト 
ネコがいろんなところ出現しゅつげんするスクリプト
ラッチ先生
ラッチ先生

There are many game projects that use this script.

We also learned programming that starts when you click a sprite.

We use the “when this sprite clicked” block.

Try using these codes to challenge yourself with game programming!

See you again!!

スック
スック

See you!

(@^^)/~~~

コメント