若您覺得文章寫得不錯,請點選文章上的廣告,來支持小編,謝謝。
太鼓達人原是一款街機遊戲,玩家配合音樂的節奏來敲打機台上的鼓。隨後很多遊戲機也推出家用版。筆者根據這款遊戲設計出底下的小遊戲來模擬(https://scratch.mit.edu/projects/218261374/):
設計方式:
1. 新增一個箭頭角色,使用內建的箭頭造型。
筆者會使用這裡的造型標號來做程式的設計,也就是
造型編號1為向左箭頭;
造型編號2為向右箭頭;
造型編號3為向下箭頭;
造型編號4為向上箭頭。
2. 新增鼓的角色,並設計四種造型
造型編號1為未打下鼓的造型;
造型編號2為打下鼓的造型;
造型編號3為得分的造型;
造型編號4為失誤的造型。
3. 程式設計部分有使用到分身、廣播、自訂函式積木等觀念。基本想法是產生箭頭的分身,並隨機選擇箭頭的造型,若箭頭與鼓的距離小於40且按下正確的鍵盤按鍵時,玩家就會獲得一分,箭頭分身就會被刪除。
4. 箭頭角色的積木程式
5. 鼓角色的積木程式
延伸練習:
如何增加遊戲的難度?例如:
1. 當分數超過100時,箭頭移動的速度就增加。
2. 玩家只能失誤3次,失誤3次遊戲就結束。
3. 不同的得分方式,當箭頭在鼓的正中央(靶心)時為Perfect的得分,其餘皆為一般Good得分。
程式設計可以改變您的未來(Programming can change your future)。 雲林SONG 全名為雲林軟體工程(SOftware eNGineering),目標致力於軟體人才的培養並推廣開源軟體落實於資訊教育。程式設計的觀念是軟體產品的基礎,程式碼就像沙子一樣,要紮實,所建立出來的高塔才會穩固。本站也提供資訊教育相關的教學資源。 YunlinSONG stands for Yunlin SOftware eNGineering, offering tutorial for computer programming and promoting open-source software. Teaching resources in information technology education are provided here.
Tinkercad Circuits:LED閃爍 (LED Blink )
若您覺得文章寫得不錯,請點選文章上的廣告,來支持小編,謝謝。
If you like this post, please click the ads on the blog or buy me a coffee. Thank you very much.- Arduino UNO R3 x 1
- LED x 1
- 220 ohm Resistor x 1
- Small Breadboard x 1
電路(Circuit):
LED blinking without breadboard
LED blinking with breadboard
The LED anode is connected to Arduino UNO pin 13. The LED cathode is connected to Arduino UNO ground.
程式碼(The Code):
上圖左邊是積木程式,右邊是 Arduino C 語言。舉例來說,左邊的 set built-in LED to HIGH 積木所對應的C語言為 digitalWrite(13, HIGH),wait 1 secs 對應的是 delay(1000)。也就是左邊的四個積木所對應的C語言程式碼是在右邊的 void loop() { .... } 裡。
The left side of the image is blocks and the right side of the image is Arduino C. For example, "set built-in LED to HIGH" is mapped to "digitalWrite(13, HIGH);" in Arduino C. That is, the four blocks on the left side of the image are mapped to the four lines of Arduino C code in the loop() body.
我們可以做底下的實驗(The Experiments):
1. 不使用電阻,LED燈會怎麼樣?What happens to LED without a resistor?
2. 將LED的正極接到Arduino 的數位腳位 4 (或其他),此時程式要怎麼修改?Connect LED anode to other Arduino digital pin(except 13). How to modify the code to let LED blinking?
示範影片(Demo Video):
範例連結(Example Link):
With breadboard: https://www.tinkercad.com/things/59tG0VQlOaF
Without breadboard: https://www.tinkercad.com/things/jj20u6LMej6
Tinkercad Circuits:簡易電路 LED 兩端不接地(Light up a LED without connecting the ground)
若您覺得文章寫得不錯,請點選文章上的廣告,來支持小編,謝謝。
If you like this post, please click the ads on the blog or buy me a coffee. Thank you very much.In this simple circuit, the reader can learn the relationship between the voltage and LED brightness.
材料(Materials):
1.5V battery x (from 2 to 5)
LED x 1
電路(Circuit):
上圖右方是LED正極的電壓;上圖左方是LED負極的電壓。
The right side is the voltage applied to LED anode. The left side is the voltage applied to LED cathode.
我們可以做底下的實驗(The Experiments):
- 讓正負極的電壓相同。(The voltage between anode and cathode is equal.)
- 讓正極的電壓大於負極。(The anode voltage is higher than the cathode voltage.)
- 讓正極的電壓小於負極。(The anode voltage is lower than the cathode voltage.)
進行實驗時,請觀察LED的亮度與正負極電壓之間的關係。
Please observe the relationship between the voltage and LED brightness during the experiment.
示範影片(Demo Video):
範例連結(Example Link):
https://www.tinkercad.com/things/9H5rd83QEir-led-#/
訂閱:
文章 (Atom)