Microbit 遊戲設計:誰是快手高手(Microbit Game Design: Who's The Fastest Clicker)

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

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

本篇文章將講解如何製作一個簡易的兩人按鈕競賽遊戲:誰是快手高手。
This article will create a simple two players microbit game: Who's the fastest clicker. 

一、遊戲功能如下(Game Design):
  • 遊戲開始時將球放在LED矩陣正中央的x,y座標(2, 2)上。Light up the LED at (2,2) when the game started.
  • 按下A按鈕時,球往左移動。The ball moves to the left when the button A is pressed.
  • 按下B按鈕時,球往右移動。The ball moves to the right when the button B is pressed.
  • 碰到牆壁時,有兩種情況:There are two conditions when the ball hits the edge:
    • 1. 左邊牆壁,球的x座標等於0時,球的y座標減 1 ,球的x座標設為4。Left edge: when the ball's x equals to 0, ball's y minus 1 and assign ball's x to 4.
    • 2. 右邊牆壁,球的x座標等於4時,球的y座標加 1 ,球的x座標設為0。Right edge: when the ball's x equals to 4, ball's y plus 1 and assign ball's x to 0.
  • 當球的座標為(0,0)或(4,4)時,遊戲結束。When the ball is in (0,0) or (4,4), the game is over.

二、積木程式(Blocks Code)
遊戲開始時將球放在LED矩陣正中央的x,y座標(2, 2)上。Light up the LED at (2,2) when the game started.


按下A按鈕時,球往左移動。The ball moves to the left when the button A is pressed.
碰到左邊牆壁,球的x座標等於0時,球的y座標減 1 ,球的x座標設為4。Left edge: when the ball's x equals to 0, ball's y minus 1 and assign ball's x to 4.



按下B按鈕時,球往右移動。The ball moves to the right when the button B is pressed.
碰到右邊牆壁,球的x座標等於4時,球的y座標加 1 ,球的x座標設為0。Right edge: when the ball's x equals to 4, ball's y plus 1 and assign ball's x to 0.



當球的座標為(0,0)或(4,4)時,遊戲結束。When the ball is in (0,0) or (4,4), the game is over.




三、結果(The Results)
影片(Demo Video):



請自由發揮額外功能,例如計分與計時等。
More Ideas examples: Scoring and game timing...etc. 

範例網址(Example Code):https://makecode.microbit.org/_ioggvUW2jCwL




沒有留言: