2016-04-01 03:16:03 +02:00
# headbands activity
2016-03-26 00:47:20 +01:00
## Before we get started
2016-03-31 02:01:28 +02:00
Your beginning code should look like this:
2016-03-26 00:47:20 +01:00
2016-03-31 02:01:28 +02:00
```blocks
2016-07-25 12:11:51 +02:00
let coll: string[] = []
2016-03-26 00:47:20 +01:00
coll.push("puppy")
coll.push("clock")
coll.push("night")
coll.push("cat")
coll.push("cow")
input.onLogoUp(() => {
2018-04-21 19:52:09 +02:00
let index = Math.randomInt(coll.length)
2016-03-26 00:47:20 +01:00
let word = coll[index]
basic.showString(word, 150)
})
input.onScreenDown(() => {
game.addScore(1)
})
game.startCountdown(30000)
```
2017-09-07 22:42:08 +02:00
## Challenge 1
2016-03-26 00:47:20 +01:00
Let's add more words for the player to act out! But first, we need to increase the time in one round to give the player more time get through all the words. Let's change the `game->start countdown` statement.
2016-03-31 02:01:28 +02:00
```blocks
2016-07-25 11:35:15 +02:00
let coll: string[] = []
2016-03-31 02:01:28 +02:00
coll.push("puppy")
coll.push("clock")
coll.push("night")
coll.push("cat")
coll.push("cow")
input.onLogoUp(() => {
2018-04-21 19:52:09 +02:00
let index = Math.randomInt(coll.length)
2016-03-31 02:01:28 +02:00
let word = coll[index]
basic.showString(word, 150)
})
input.onScreenDown(() => {
game.addScore(1)
})
game.startCountdown(60000)
2016-03-26 00:47:20 +01:00
```
* Run your code to see if it works as expected
2017-09-07 22:42:08 +02:00
## Challenge 2
2016-03-26 00:47:20 +01:00
Now let's add 5 more words to our list of charade words. Right above the the line `word:=coll->at(index)` add 5 lines that say `coll->add("")` . In this example, we will add the words **bicycle, telephone, sun, car, and ant** but you can add whatever words you like.
2016-03-31 02:01:28 +02:00
```blocks
2016-07-25 11:35:15 +02:00
let coll: string[] = []
coll.push("puppy")
2016-03-26 00:47:20 +01:00
coll.push("clock")
coll.push("night")
coll.push("cat")
coll.push("cow")
2016-03-31 02:01:28 +02:00
coll.push("bicycle")
coll.push("telephone")
coll.push("sun")
coll.push("car")
coll.push("ant")
input.onLogoUp(() => {
2018-04-21 19:52:09 +02:00
let index = Math.randomInt(coll.length)
2016-03-31 02:01:28 +02:00
let word = coll[index]
basic.showString(word, 150)
})
input.onScreenDown(() => {
game.addScore(1)
})
game.startCountdown(30000)
2016-03-26 00:47:20 +01:00
```
* 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
Remove a life using `game->remove life` when the screen is down using the `input->on screen down` event.
2017-09-07 22:42:08 +02:00
## Challenge 4
2016-03-26 00:47:20 +01:00
The collection has a function `random` that returns a random element. Update your code to use this function instead of using `math->random` .
2017-09-07 22:42:08 +02:00
## Challenge 5!
2016-03-26 00:47:20 +01:00
Play the game and try guessing all these words in less than 2 minutes!