# 真心话大冒险

• 年龄 8+
• 30 分钟
• MakeCode Editor

## 课堂活动

5个步骤

### 第一步

Drag the “Show leds” block onto the workspace and draw the pattern by clicking on the boxes that you want to light up. A white square indicates LED on.

``````
basic.forever(function () {
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
})
``````

### 第二步

``````
let item = 0
input.onButtonPressed(Button.A, function () {
item = 0
})
``````

### 第三步

``````
let Random = 0
input.onButtonPressed(Button.A, function () {
Random = 0
})
``````

Now that the variable is set to “0” when the A button is pressed, we now need to assign a random number to it. From the block menu select the “Math” option and select “pick random 0 to 10”

``````
let Random = 0
input.onButtonPressed(Button.A, function () {
Random = Math.randomRange(0, 1)
})
``````

### 第四步

Drag the “IF” block into the workspace and connect it to follow the “random” block; click '+' to add 'else' to the block.

``````
let Random = 0
input.onButtonPressed(Button.A, function () {
Random = Math.randomRange(0, 1)
if (true) {

} else {

}
})
``````

``````
let Random = 0
input.onButtonPressed(Button.A, function () {
Random = Math.randomRange(0, 1)
if (0 == 0) {

} else {

}
})
``````

### 第五步

``````
let Random = 0
input.onButtonPressed(Button.A, function () {
Random = Math.randomRange(0, 1)
if (Random == 0) {

} else {

}
})
``````

To get the "Truth or Dare" statements displayed on the screen the “show string” block is required from the basic option on the block menu.

``````
let Random = 0
input.onButtonPressed(Button.A, function () {
Random = Math.randomRange(0, 1)
if (Random == 0) {
basic.showString("Truth")
} else {
basic.showString("Dare")
}
})
``````

## 挑战

• 在游戏中添加玩家的序号，并显示谁在玩。
• 添加箭头的不同方向。
• 添加一个箭头旋转的动画。
• 添加一个基于分数的系统，看看是否答对了truth（真）或dare（假）。

## 了解更多

“魔术8”活动是以这个项目为基础创建的一个基于问题的游戏。