2016-03-26 00:47:20 +01:00
# truth or dare challenges
A multi-player game that forces each player to reveal a secret or something funny.
## Before we get started
2016-04-13 17:27:45 +02:00
Complete the following [guided tutorial ](/lessons/truth-or-dare/activity ), and your code should look like this
2016-03-26 00:47:20 +01:00
```blocks
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
input.onButtonPressed(Button.A, () => {
let random = Math.random(2)
if (random == 0) {
basic.showString("TRUTH")
} else {
basic.showString("DARE")
}
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
})
```
2017-09-07 22:42:08 +02:00
## Challenge 1
2016-03-26 00:47:20 +01:00
Let's make the word "DARE" appear a little more often than "TRUTH". Change the line of code with `pick random (1)` to `pick random (2)` .
```blocks
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
input.onButtonPressed(Button.A, () => {
let random = Math.random(3)
if (random == 0) {
basic.showString("TRUTH")
} else {
basic.showString("DARE")
}
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
})
```
2017-09-07 22:42:08 +02:00
## Challenge 2
2016-03-26 00:47:20 +01:00
2016-11-02 01:44:37 +01:00
Instead of just saying "TRUTH" or "DARE", let's sometimes say "SKIP". This would allow the skipped person to spin the @boardname @ without completing a truth or dare. Modify the if statement as shown.
2016-03-26 00:47:20 +01:00
``` blocks
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
input.onButtonPressed(Button.A, () => {
let random = Math.random(2)
if (random == 1) {
basic.showString("TRUTH")
} else if (random == 0) {
basic.showString("DARE")
} else {
basic.showString("SKIP")
}
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
})
```
* Run your code to see if it works as expected
2017-09-07 22:42:08 +02:00
## Challenge 3
2016-03-26 00:47:20 +01:00
2016-11-02 01:44:37 +01:00
Add some other messages, such as "TWO DARES" for the @boardname @ to show. You will need to modify the parameter inside `pick random (3)` as well as adding another `if` condition.
2016-03-26 00:47:20 +01:00