2016-03-25 16:47:20 -07:00
|
|
|
# bop it quiz answers
|
|
|
|
|
2016-04-01 16:22:47 -07:00
|
|
|
a game where you have to keep up with the commands.
|
2016-03-25 16:47:20 -07:00
|
|
|
|
|
|
|
## Name
|
|
|
|
|
|
|
|
## Directions
|
|
|
|
|
2016-04-15 15:02:26 -07:00
|
|
|
Use this activity document to guide your work in the [bop it activity](/lessons/bop-it/activity).
|
2016-03-25 16:47:20 -07:00
|
|
|
|
|
|
|
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
|
|
|
|
|
|
|
## 1. Write the code that will store the global variable named 'action' and returns a random number between 0 and 2
|
|
|
|
|
2016-05-09 10:32:02 -07:00
|
|
|
```blocks
|
2018-06-01 11:42:38 -07:00
|
|
|
let action = Math.randomRange(0, 3)
|
2016-03-25 16:47:20 -07:00
|
|
|
```
|
|
|
|
|
|
|
|
## 2. Write the code that will display the string, "PUSH A" if the global variable called 'action' is equal to 0
|
|
|
|
|
2016-05-09 10:32:02 -07:00
|
|
|
```blocks
|
2018-06-01 11:42:38 -07:00
|
|
|
let action = Math.randomRange(0, 3)
|
2016-03-25 16:47:20 -07:00
|
|
|
if (action == 0) {
|
2018-11-09 15:36:46 -08:00
|
|
|
basic.showString("PUSH A")
|
2016-03-25 16:47:20 -07:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## 3. Write the code that increments the score if button A is pressed when the global variable called 'action' is equal to 1
|
|
|
|
|
2016-05-09 10:32:02 -07:00
|
|
|
```blocks
|
2016-03-29 21:17:57 -07:00
|
|
|
input.onButtonPressed(Button.A, () => {
|
2018-06-01 11:42:38 -07:00
|
|
|
let action = Math.randomRange(0, 3)
|
2016-03-25 16:47:20 -07:00
|
|
|
if (action == 0) {
|
|
|
|
game.addScore(1)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
|
|
|
## 4. Write the code that will display the string "LOGO DOWN" if the global variable called 'action' is equal to 1
|
|
|
|
|
2016-05-09 10:32:02 -07:00
|
|
|
```blocks
|
2018-06-01 11:42:38 -07:00
|
|
|
let action = Math.randomRange(0, 3)
|
2016-03-25 16:47:20 -07:00
|
|
|
if (action == 1) {
|
2018-11-09 15:36:46 -08:00
|
|
|
basic.showString("LOGO DOWN")
|
2016-03-25 16:47:20 -07:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2016-11-01 10:42:42 -07:00
|
|
|
## 5. Write the code that increments the score if the @boardname@ logo is tilted down when the global variable called 'action' is equal to 1
|
2016-03-25 16:47:20 -07:00
|
|
|
|
2016-05-09 10:32:02 -07:00
|
|
|
```blocks
|
2018-11-09 15:36:46 -08:00
|
|
|
input.onGesture(Gesture.LogoDown, function () {
|
2018-06-01 11:42:38 -07:00
|
|
|
let action = Math.randomRange(0, 3)
|
2016-03-25 16:47:20 -07:00
|
|
|
if (action == 1) {
|
|
|
|
game.addScore(1)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
|
|
|
## 6. Write the code that will display the string "SHAKE" if the global variable called 'action' is equal to 2
|
|
|
|
|
2016-05-09 10:32:02 -07:00
|
|
|
```blocks
|
2018-06-01 11:42:38 -07:00
|
|
|
let action = Math.randomRange(0, 3)
|
2016-03-25 16:47:20 -07:00
|
|
|
if (action == 2) {
|
2018-11-09 15:36:46 -08:00
|
|
|
basic.showString("SHAKE")
|
2016-03-25 16:47:20 -07:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2016-11-01 10:42:42 -07:00
|
|
|
## 7. Write the code that increments the score if the @boardname@ is shaken when the global variable called 'action' is equal to 2
|
2016-03-25 16:47:20 -07:00
|
|
|
|
2016-05-09 10:32:02 -07:00
|
|
|
```blocks
|
2018-11-09 15:36:46 -08:00
|
|
|
input.onGesture(Gesture.LogoDown, function () {
|
2018-06-01 11:42:38 -07:00
|
|
|
let action = Math.randomRange(0, 3)
|
2016-03-25 16:47:20 -07:00
|
|
|
if (action == 1) {
|
|
|
|
game.addScore(1)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
```
|