![ラッチ先生](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)
前回の「ねっち あみだくじ#1」では、
- 毎回、あみだくじが 変わる
プログラミングをしました。
![スック](https://scratchsiyou.com/wp-content/uploads/2022/05/sukku_futu-2-300x300.png)
なにが でるかなぁ、
なにが でるかなぁ…。
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2021/12/ratch_kao_dounaru.png)
今回は、この「ねっち あみだくじ#1」に
- 「ねっち」が、あみだくじを 通る
プログラムを追加していきます。
![スック](https://scratchsiyou.com/wp-content/uploads/2022/05/sukku_futu-1-300x300.png)
まだ「ねっち あみだくじ#1」の
- 毎回、あみだくじが 変わる
プログラミングをしてない人は、
こちらの記事を見てね!
それでは、楽しくプログラミングを学んでいきましょう!
今回作るスクラッチの作品は、これっ!
![スック](https://scratchsiyou.com/wp-content/uploads/2022/01/sukku_futu-300x300.png)
あたった?
今回のプログラミングで学ぶことは
2.ねっちが あみだくじを通るスクリプトがわかるよ
![「スクラッチしよう!10-33 ねっちあみだくじ!#2」 scratch あみだくじを通る](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1032_explanation16.png)
追加プログラミングの仕方を 説明します
ねっちのスクリプト
コスチュームに「センサー」を 描く
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2022/04/ratch_kao_dounaru-1.png)
ねっちが 横棒に触れたら、曲がるように
コスチュームに「センサー」を 描きます。
![「スクラッチしよう!10-33 ねっちあみだくじ!#2」 scratch センサー](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation6-1.png)
![スック](https://scratchsiyou.com/wp-content/uploads/2022/01/sukku_futu-300x300.png)
進む方向から見ての 右や左。
「ねっち」は下に進んでいるから、「右」と「左」は反対になるよ!
ちょっと、ややこしいね!
1.左センサーを 描く
![「スクラッチしよう!10-33 ねっちあみだくじ!#2」 scratch 左センサーを描く](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation15-1.png)
2.右センサーを 描く
![「スクラッチしよう!10-33 ねっちあみだくじ!#2」 scratch 右センサーを描く](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation16-1.png)
3.向きを 変える
![「スクラッチしよう!10-33 ねっちあみだくじ!#2」 scratch 向きを変える](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation17.png)
![スック](https://scratchsiyou.com/wp-content/uploads/2022/05/sukku_futu-2-300x300.png)
これで、「ねっち」のコスチュームが 完成だよ
ねっちが 左に回るプログラミング
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2022/04/ratch_kao_dounaru-1.png)
「○度に向ける」ブロックを 使って
![scratch 「○度に向ける」ブロック](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation18.png)
下に向けて端まで動くプログラム
![「スクラッチしよう!10-33 ねっちあみだくじ!#2」 scratch 端まで動くプログラム](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation19.png)
を、作ろう!
1.下の端まで 動く
![「スクラッチしよう!10-33 ねっちあみだくじ!#2」 scratch 下に動くスクリプト](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation22.png)
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2021/12/ratch_kao_dounaru.png)
つぎに、
「○色が○色に触れた」ブロックを使って
![scratch 「○色が○色に触れた」ブロック](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation24.png)
![スック](https://scratchsiyou.com/wp-content/uploads/2022/05/sukku_futu-2-300x300.png)
赤は、左センサーの色。
黒は、あみだくじの色。
1,コード「調べる」から 「○色が○色に触れる」ブロックをスクリプトエリアに出す
![「スクラッチしよう!10-33 ねっちあみだくじ!#2」 scratch 「○色が○色に触れた」ブロック](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation31.png)
2,ステージに 円を出して、色センターに□を合わせて クリックする
![「スクラッチしよう!10-33 ねっちあみだくじ!#2」 scratch 色センサーの色にする](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation32-1.png)
3,円の□をあみだくじに合わせて、クリックする
![「スクラッチしよう!10-33 ねっちあみだくじ!#2」 scratch あみだくじの色にする](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation33.png)
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2021/12/ratch_kao_dounaru.png)
左センサーが「横棒」に触れたら 左に回るプログラム
![「スクラッチしよう!10-33 ねっちあみだくじ!#2」 scratch 横棒(右)に触れたら曲がるスクリプト](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation23.png)
を、作ります。
2,左センサーが横棒に触れたら、左に回る
![「スクラッチしよう!10-33 ねっちあみだくじ!#2」 scratch 左に曲がるスクリプト](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation25-1.png)
![スック](https://scratchsiyou.com/wp-content/uploads/2022/09/sukku_are-300x300.png)
あれっ?!
ねっちが 上に のぼっていくよ!
![「スクラッチしよう!10-33 ねっちあみだくじ!#2」 scratch ねっちがあみだくじの上に行く](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation37-1.png)
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2022/09/ratch_kao_yes-300x300.png)
おおっと!
ねっちの向きが90度の時に、あみだくじに触れて左に曲がると 上に行くから
![「スクラッチしよう!10-33 ねっちあみだくじ!#2」 scratch ねっちの向きが90度](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation39.png)
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2022/09/ratch_kao_dounaru.png)
「○ではない」ブロックを使って、
![scratch 「○ではない」](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation40.png)
左センサーが、あみだくじの棒の触れて左に回る条件を
- 【条件1】左センサーがあみだくじに 触れる
![](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation24-1.png)
- 【条件2】ねっちの向きが、90度ではない
![scratch 「向きが90度でない」ブロック](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation41.png)
この2つに します。
![スック](https://scratchsiyou.com/wp-content/uploads/2022/05/sukku_are-2-300x300.png)
「○ではない」ブロックは、
![scratch 「○ではない」ブロック](https://scratchsiyou.com/wp-content/uploads/2022/05/scratchsiyoutitle1015_explanation29.png)
○の反対になるんだよね。
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2021/12/ratch_kao_dounaru.png)
そう。
この2つの条件を両方ともO.Kするには、
「○かつ○」ブロックを使って、
![scratch 「○かつ○」ブロック](https://scratchsiyou.com/wp-content/uploads/2022/05/scratchsiyoutitle1015_explanation33.png)
「左センサーが あみだくじに触れる、かつ、向きが90度ではない」ブロックを作ります。
![scratch 「左センサーが あみだくじに触ふれる、かつ、向むきが90度どではない」ブロック](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation42.png)
3.左センサーが横棒に触れたら、左に曲がる(上に のぼらない)
![「スクラッチしよう!10-33 ねっちあみだくじ!#2」 scratch 左に回るスクリプト](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation61.png)
![スック](https://scratchsiyou.com/wp-content/uploads/2022/09/sukku_futu-300x300.png)
うん、上に行かないね。
ねっちが 右に回るプログラミング
1.右センサーが横棒に触れたら、右に回る
![「スクラッチしよう!10-33 ねっちあみだくじ!#2」 scratch 右に回るスクリプト](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation51-1.png)
![スック](https://scratchsiyou.com/wp-content/uploads/2022/09/sukku_futu-300x300.png)
これだと、
ねっちが 上に のぼっていくね!
![「スクラッチしよう!10-33 ねっちあみだくじ!#2」 scratch 右に回るスクリプト](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation48.png)
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2022/09/ratch_kao_dounaru.png)
そうですね。
ねっちの向きが-90度の時に、あみだくじに触れて右に曲がると 上に行くから
![「スクラッチしよう!10-33 ねっちあみだくじ!#2」 scratch ねっちの向きは-90度](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation55.png)
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2022/09/ratch_kao_dounaru.png)
右センサーが、あみだくじの棒の触れて右に回る条件を
- 【条件1】右センサーがあみだくじに 触れる
![scratch 「○色が○色に触れた」ブロック](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation56.png)
- 【条件2】ねっちの向きが、-90度ではない
![scratch 「向きが90度ではない」ブロック](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation57.png)
この2つに します。
2.右センサーが横棒に触れたら、右に曲がる(上に のぼらない)
![「スクラッチしよう!10-33 ねっちあみだくじ!#2」 scratch 右に回るスクリプト](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation60-1.png)
バグったぁー!
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2022/09/ratch_kao_dounaru.png)
これで、ねっちが あみだくじを通るプログラムができました…。
![「スクラッチしよう!10-33 ねっちあみだくじ!#2」 scratch ねっちがあみだくじを通るスクリプト](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation68.png)
![スック](https://scratchsiyou.com/wp-content/uploads/2022/09/sukku_are-300x300.png)
ラッチ先生。
ねっちが 回らないよ…。
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2022/09/ratch_kao_yes-300x300.png)
あちゃ~、ほんとだ。バグりましたね。
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2022/09/ratch_kao_dounaru.png)
こういう時は、じっくり ねっちの動きを見てみよう。
このプログラムだと、
- どのような現象(バグ)が起きるか
- なぜ、起きるのか
- そのための対策
この3点を動画で説明しますので、見てください。
![スック](https://scratchsiyou.com/wp-content/uploads/2022/06/sukku_futu-1-300x300.png)
はぁーい。
フリーBGM:DOVA-SYNDROME 午後のカメレオンは星の波動を数え… written by Masuo
![スック](https://scratchsiyou.com/wp-content/uploads/2022/06/sukku_futu-1-300x300.png)
なるほどね。
ねっちが90度回ると、
また、センサーが あみだくじに触れるのが
原因なんだね
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2022/06/ratch_kao_yes-1-300x300.png)
そのとおり!
なので、このバグを解消するために、
- センサーが、あみだくじに触れる
- 90度 回す
- 5歩 動かす
と、プログラミングしていきましょう。
![スック](https://scratchsiyou.com/wp-content/uploads/2022/06/sukku_futu-1-300x300.png)
うん。
3.左に 回る(バグなし)
![「スクラッチしよう!10-33 ねっちあみだくじ!#2」 scratch 左に回るスクリプト](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation65-1.png)
4.右に 回る(バグなし)
![「スクラッチしよう!10-33 ねっちあみだくじ!#2」 scratch 右に回るスクリプト](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation67.png)
5.あみだくじを 通る
![「スクラッチしよう!10-33 ねっちあみだくじ!#2」 scratch ねっちがあみだくじを通るスクリプト](https://scratchsiyou.com/wp-content/uploads/2022/09/scratchsiyoutitle1033_explanation70.png)
![スック](https://scratchsiyou.com/wp-content/uploads/2022/09/sukku_ok-1-300x300.png)
できたぁー!
つづく・・・
![スック](https://scratchsiyou.com/wp-content/uploads/2022/07/sukku_are-300x300.png)
あれあれ。
まだ終わってないよ。
![ラッチ先生<br>](https://scratchsiyou.com/wp-content/uploads/2022/09/ratch_kao_yes-300x300.png)
いやぁ~、ここで休憩!
次回は、
「ねっち あみだくじ」の
- クリックした所から、ねっちがスタートする
- 当たりが、ランダムに決まる
プログラミングを紹介します。
![スック](https://scratchsiyou.com/wp-content/uploads/2022/09/sukku_futu-300x300.png)
うん、わかった!。
![ラッチ先生<br>](https://scratchsiyou.com/wp-content/uploads/2021/12/ratch_kao_dounaru.png)
楽しみに待っててね!
それじゃあ、またぁ!
![スック](https://scratchsiyou.com/wp-content/uploads/2021/12/sukku_futu-300x300.png)
まったねえーーー!
(@^^)/~~~
ステップアップドリル
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2021/12/ratch_kao_dounaru.png)
「変数」って、なあに?
「変数」ブロックって、どう使うの?
と 思っている方に!
変数ブロックでのプログラミングを 学べるドリルを 作りました
![ラッチ先生](https://scratchsiyou.com/wp-content/uploads/2021/12/ratch_kao_dounaru.png)
「リスト」って、なあに?
「リスト」ブロックって、どう使うの?
と 思っている方はこちら!
リストブロックでのプログラミングを 学べるドリルを 作りました
![スック](https://scratchsiyou.com/wp-content/uploads/2022/01/sukku_futu-300x300.png)
画面を クリックすると
「ステップアップドリル」のサイトへ 行けます!
コメント