EV3 認識方向符號小遊戲(EV3 Direction Game)

若您覺得文章寫得不錯,請點選文章上的廣告,來支持小編,謝謝。

If you like this post, please click the ads on the blog or buy me a coffee. Thank you very much.

一、遊戲設計規劃(Game Design)
EV3 主機上有六顆按鈕(圖片來源:https://www.ev3dev.org/docs/tutorials/using-ev3-buttons/)
There are six buttons on EV3 brick

1:BACKSPACE 後退
2:UP 向上
3:LEFT 向左
4:ENTER 確認(進入)
5:RIGHT 向右
6:DOWN 向下

我們可以設計一個會顯示上、下、左、右的四個箭頭來玩遊戲認識箭頭方向的小程式。程式流程如下:
1. 程式開始時,播放歡迎音效。
2. 每一秒取 0 到 3 的亂數,分別用來顯示上、下、左、右的四個箭頭,數字代表箭頭符號如下表示:
  • 數字 0 為 向上箭頭
  • 數字 1 為 向左箭頭
  • 數字 2 為 向右箭頭
  • 數字 3 為 向下箭頭
3. 按下對應的箭頭按鈕時,清除畫面並播放音效。

We could design a simple game to understand the direction symbols. The program flow is:
1. Play a welcome sound when the game is started.
2. Pick up a [0-3] random that indicates each direction symbol every second. Number has its' meaning as the following:
  • Number 0 is up arrow.
  • Number 1 is left arrow.
  • Number 2 is right arrow.
  • Number 3 is down arrow.
3. When a button is pressed, clear the screen and play a sound.

二、遊戲程式積木(The Game Blocks)
程式開始時,播放歡迎音效。Play a welcome sound when the game is started.



每一秒取 0 到 3 的亂數,分別用來顯示上、下、左、右的四個箭頭。Pick up a [0-3] random that indicates each direction symbol every second.



按下對應的箭頭按鈕時,清除畫面並播放音效。When a button is pressed, clear the screen and play a sound.



三、結果(The Result)
影片(Video):


MakeCode Mindstorm Project 專案範例網址:https://makecode.com/_hiDJUH6oiMPU

沒有留言: