![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2021/12/ratch_kao_dounaru.png)
こんにちは!
「ステップアップドリル:変数ブロックの使い方入門」に ようこそ!
「スクラッチしよう!楽しく学ぶプログラミング教室」の担任ラッチです。
![スック](https://scratchsiyou.com/wp-content/uploads/2022/01/sukku_futu-300x300.png)
スックだよ!
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2021/12/ratch_kao_dounaru.png)
今回の「ステップアップドリル」で作る作品は、こちら!
![「スクラッチしよう!8-1-03 ステップアップドリル:ハートが 出て!」 scratch](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-gif2.gif)
![スック](https://scratchsiyou.com/wp-content/uploads/2022/01/sukku_futu-300x300.png)
ボールを タップして ハートが出たら、
クリアだよ!
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2021/12/ratch_kao_dounaru.png)
「ハート」と「ねっち」の場所は、 ランダムです
![「スクラッチしよう!8-1-03 ステップアップドリル:ハートが 出て!」 scratch 「ハート」と「ねっち」の位置](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-gif4.gif)
ローカル変数「番号」ブロックが 使われているんだ
![「スクラッチしよう!8-1-03 ステップアップドリル:ハートが 出て!」 scratch 変数ブロック](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-explanation1.png)
![変数表示](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-explanation2.png)
![このスプライトのみ](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-explanation3.png)
![スック](https://scratchsiyou.com/wp-content/uploads/2023/09/sukku_are-300x300.png)
あっ!ほんとだ
毎回 ちがうね
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2021/12/ratch_kao_dounaru.png)
はい!
それでは、ローカル変数が どのように使われているか 学んでいこう
![スック](https://scratchsiyou.com/wp-content/uploads/2023/09/sukku_ok-300x300.png)
いいよ!
今回作るスクラッチの作品は、これっ!
![「スクラッチしよう!8-1-03 ステップアップドリル:ハートが 出て!」 scratch](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-gif5.gif)
![スック](https://scratchsiyou.com/wp-content/uploads/2023/07/sukku_futu-1-300x300.png)
楽しいよ
今回のプログラミングで 学ぶことは
1.ボールを 横5個×4段に 表示する スクリプトが わかるよ
![「スクラッチしよう!8-1-03 ステップアップドリル:ハートが 出て!」 scratch ボールを横5個×4段に表示する](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-gif7.gif)
2.「ハート」と「ねっち」の場所を ランダムにする スクリプトが わかるよ
![「スクラッチしよう!8-1-03 ステップアップドリル:ハートが 出て!」 scratch 「ハート」と「ねっち」をランダムに配置する](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-gif8.gif)
3.クリア、ゲームオーバーの スクリプトが わかるよ
![「スクラッチしよう!8-1-03 ステップアップドリル:ハートが 出て!」 scratch クリア・ゲームオーバー](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-gif9.gif)
プログラミングの仕方を説明します
ボールを ならべるプログラミング
1.ボールを 横5個×4段に 表示する スクリプトが わかるよ
![「スクラッチしよう!8-1-03 ステップアップドリル:ハートが 出て!」 scratch ボールを横5個×4段に表示する](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-gif7.gif)
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2021/12/ratch_kao_dounaru.png)
最初に、スプライト「ボール」を 追加します
![「スクラッチしよう!8-1-03 ステップアップドリル:ハートが 出て!」 scratch スプライト「ボール」](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-explanation4-800x554.png)
![「スクラッチしよう!8-1-03 ステップアップドリル:ハートが 出て!」 scratch スプライト「ボール」コスチューム](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-explanation6-2.png)
![スック](https://scratchsiyou.com/wp-content/uploads/2023/07/sukku_futu-1-300x300.png)
スプライト「Ball」を 追加
名前を 「ボール」に したよ!
コスチュームは、4つ 作るよ
フリーBGM:DOVA-SYNDROME 午後のカメレオンは星の波動を数え… written by Masuo
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2021/12/ratch_kao_dounaru.png)
それでは、スプライト「ボール」の
![「スクラッチしよう!8-1-03 ステップアップドリル:ハートが 出て!」 scratch スプライト「ボール」](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-explanation8.png)
プログラムを 作りましょう。
![スック](https://scratchsiyou.com/wp-content/uploads/2022/10/sukku_futu-300x300.png)
はぁ~い!
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2021/12/ratch_kao_dounaru.png)
まず、「x座標を○、y座標を○にする」ブロックを 使って
![「x座標を○、y座標を○にする」ブロック](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-explanation9.png)
ボールの場所を 決めます
1.ボールを 1段目の左端に 表示する
![「スクラッチしよう!8-1-03 ステップアップドリル:ハートが 出て!」 scratch ボールを左端に表示するスクリプト](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-explanation13-800x583.png)
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2021/12/ratch_kao_dounaru.png)
ボールを 横5個 並べるプログラムです
1.クローンを作って 右に移動する:5回繰り返す
![「スクラッチしよう!8-1-03 ステップアップドリル:ハートが 出て!」 scratch 横5個並べるプログラム①](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-explanation19-1.png)
2.左端に もどる
![「スクラッチしよう!8-1-03 ステップアップドリル:ハートが 出て!」 scratch 横5個並べるプログラム②](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-explanation20-2.png)
3.次の段の 左端の場所に 移動する
![「スクラッチしよう!8-1-03 ステップアップドリル:ハートが 出て!」 scratch 横5個並べるプログラム③](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-explanation22.png)
2.ボールを 横5個 並べる
![「スクラッチしよう!8-1-03 ステップアップドリル:ハートが 出て!」 scratch 横5個並べるスクリプト](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-gif11.gif)
![スック](https://scratchsiyou.com/wp-content/uploads/2022/10/sukku_futu-300x300.png)
ボールの「クローン」が
![ボール「クローン」](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-explanation14.png)
ならんでいくね!
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2021/12/ratch_kao_dounaru.png)
「○回繰り返す」ブロックで
![「○回繰り返す」ブロック](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-explanation24.png)
横5個並べるプログラムを 4回繰り返して、
ボール5個を 4段 表示するよ
2.ボールを 横5個 4段 並べる
![「スクラッチしよう!8-1-03 ステップアップドリル:ハートが 出て!」 scratch 横5個 4段 並べるスクリプト①](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-gif13-1.gif)
![スック](https://scratchsiyou.com/wp-content/uploads/2023/10/sukku_are-300x300.png)
あっ!
最後 ポツンを1つ ボールが 残るね
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2021/12/ratch_kao_dounaru.png)
そうなんだ!
スプライト「ボール」が
![「スクラッチしよう!8-1-03 ステップアップドリル:ハートが 出て!」 scratch スプライト「ボール」](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-explanation15.png)
最後 残るんだね。
![スック](https://scratchsiyou.com/wp-content/uploads/2023/10/sukku_futu-300x300.png)
うん、うん。
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2021/12/ratch_kao_dounaru.png)
それで、
「隠す」ブロックを 使って
![「隠す」ブロック](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-explanation26.png)
このスプライト「ボール」を 隠すよ
3.スプライト「ボール」を 隠す
![「スクラッチしよう!8-1-03 ステップアップドリル:ハートが 出て!」 scratch 横5個 4段 並べるスクリプト②](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-gif15.gif)
![スック](https://scratchsiyou.com/wp-content/uploads/2023/10/sukku_futu-300x300.png)
「表示する」ブロックは、
![「表示する」ブロック](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-explanation28.png)
次、緑の旗をクリックされたときに
スプライト「ボール」を 表示させるためだよ
「ハート」「ねっち」の場所を決めるプログラミング
2.「ハート」と「ねっち」の場所を ランダムにする スクリプトが わかるよ
![「スクラッチしよう!8-1-03 ステップアップドリル:ハートが 出て!」 scratch 「ハート」と「ねっち」をランダムに配置する](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-gif8.gif)
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2021/12/ratch_kao_dounaru.png)
つぎは、
「ハート」と「ねっち」の場所を 決めるプログラムを 作ります。
![スック](https://scratchsiyou.com/wp-content/uploads/2023/10/sukku_futu-300x300.png)
はぁ~い!
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2021/12/ratch_kao_dounaru.png)
「ハート」と「ねっち」の場所を 決めるプログラムです
1.ボールに 番号を つける
![「スクラッチしよう!8-1-03 ステップアップドリル:ハートが 出て!」 scratch 20個のボールに番号をつける](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-explanation29-1.png)
2.「ハート」の 場所を 決める
![「スクラッチしよう!8-1-03 ステップアップドリル:ハートが 出て!」 scratch 「ハート」の場所を決める](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-explanation50.png)
3.「ねっち」の 場所を 決める
![「スクラッチしよう!8-1-03 ステップアップドリル:ハートが 出て!」 scratch 「ねっち」の番号を決める](https://scratchsiyou.com/wp-content/uploads/2023/10/scratchdrillocal03-explanation49.png)
コメント