2018-04-04 02:55:15 +02:00
# What Animal Am I?
2018-05-05 01:23:53 +02:00
## Introduction @unplugged
2018-04-04 02:55:15 +02:00
2018-04-05 00:12:55 +02:00
Create different animal effects with your @boardname @.
2018-04-04 02:55:15 +02:00
![Guess the what the animal is ](/static/tutorials/what-animal-am-i/guess-animal.gif )
## Step 1
Open the ``||brick:Brick||`` Toolbox drawer. Drag out a ``||brick:show string||`` block from the **Screen** section onto the Workspace, and drop it into the ``||loops:on start||`` block. You should hear and see the block click into place.
2018-05-07 22:20:10 +02:00
```blocks
2018-04-04 02:55:15 +02:00
brick.showString("Hello world", 1)
```
## Step 2
2018-06-22 16:06:31 +02:00
In the ``||brick:show string||`` block, type the text ``"Guess the animal"`` to replace ``"Hello world"``.
2018-04-04 02:55:15 +02:00
2018-04-05 00:12:55 +02:00
```blocks
2018-06-12 15:46:44 +02:00
brick.showString("Guess the animal", 1)
2018-04-04 02:55:15 +02:00
```
## Step 3
2018-06-12 15:46:44 +02:00
Open the ``||brick:Brick||`` Toolbox drawer. From the **Buttons** section, drag out an ``||brick:on button||`` block anywhere onto the Workspace.
2018-04-04 02:55:15 +02:00
2018-04-05 00:12:55 +02:00
```blocks
2018-04-04 02:55:15 +02:00
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
})
2018-06-12 15:46:44 +02:00
brick.showString("Guess the animal", 1)
2018-04-04 02:55:15 +02:00
```
## Step 4
In the ``||brick:on button||`` block, use the drop-down menu to select the ``left`` button.
![Dropdown with button choices ](/static/tutorials/what-animal-am-i/on-button-dropdown.png )
2018-04-05 00:12:55 +02:00
```blocks
2018-04-04 02:55:15 +02:00
brick.buttonLeft.onEvent(ButtonEvent.Pressed, function () {
})
2018-06-12 15:46:44 +02:00
brick.showString("Guess the animal", 1)
2018-04-04 02:55:15 +02:00
```
## Step 5
2018-04-06 02:32:32 +02:00
Open the ``||brick:Brick||`` Toolbox drawer. In the **Buttons** section, drag out **3** more ``||brick:on button||`` blocks. Using the drop-down menu, select the ``right``, ``up``, and ``down`` buttons for these 3 blocks.
2018-04-04 02:55:15 +02:00
2018-04-05 00:12:55 +02:00
```blocks
2018-04-04 02:55:15 +02:00
brick.buttonLeft.onEvent(ButtonEvent.Pressed, function () {
})
brick.buttonRight.onEvent(ButtonEvent.Pressed, function () {
})
brick.buttonUp.onEvent(ButtonEvent.Pressed, function () {
})
brick.buttonDown.onEvent(ButtonEvent.Pressed, function () {
})
2018-06-12 15:46:44 +02:00
brick.showString("Guess the animal", 1)
2018-04-04 02:55:15 +02:00
```
## Step 6
Open the ``||brick:Brick||`` Toolbox drawer. Drag out **4** ``||brick:show image||`` blocks onto the Workspace, and drop one of them into each of the ``||brick:on button||`` blocks.
2018-04-05 00:12:55 +02:00
```blocks
2018-04-04 02:55:15 +02:00
brick.buttonLeft.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.expressionsBigSmile)
})
brick.buttonRight.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.expressionsBigSmile)
})
brick.buttonUp.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.expressionsBigSmile)
})
brick.buttonDown.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.expressionsBigSmile)
})
2018-06-12 15:46:44 +02:00
brick.showString("Guess the animal", 0)
2018-04-04 02:55:15 +02:00
```
## Step 7
In the ``||brick:show image||`` blocks, use the drop-down menu to select a different image to show for each block.
![Dropdown with image selection ](/static/tutorials/what-animal-am-i/show-image-dropdown.png )
2018-04-05 00:12:55 +02:00
```blocks
2018-04-04 02:55:15 +02:00
brick.buttonLeft.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.expressionsMouth2shut)
})
brick.buttonRight.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.expressionsMouth1open)
})
brick.buttonUp.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.objectsBoom)
})
brick.buttonDown.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.objectsPirate)
})
2018-06-12 15:46:44 +02:00
brick.showString("Guess the animal", 0)
2018-04-04 02:55:15 +02:00
```
## Step 8
2018-04-06 02:32:32 +02:00
Open the ``||music:Music||`` Toolbox drawer. Drag out **4** ``||music:play sound effect||`` block and drop one of them into each of the ``||brick:on button||`` blocks, just after the ``||brick:show image||`` block.
2018-04-04 02:55:15 +02:00
2018-04-05 00:12:55 +02:00
```blocks
2018-04-04 02:55:15 +02:00
brick.buttonLeft.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.expressionsMouth2shut)
music.playSoundEffect(sounds.animalsCatPurr)
})
brick.buttonRight.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.expressionsMouth1open)
music.playSoundEffect(sounds.animalsCatPurr)
})
brick.buttonUp.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.objectsBoom)
music.playSoundEffect(sounds.animalsCatPurr)
})
brick.buttonDown.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.objectsPirate)
music.playSoundEffect(sounds.animalsCatPurr)
})
2018-06-12 15:46:44 +02:00
brick.showString("Guess the animal", 0)
2018-04-04 02:55:15 +02:00
```
## Step 9
In each ``||music:play sound effect||`` block, use the drop-down menu to select a different animal sound to play.
![Dropdown with sound effect selection ](/static/tutorials/what-animal-am-i/play-sound-effect-dropdown.png )
2018-04-05 00:12:55 +02:00
```blocks
2018-04-04 02:55:15 +02:00
brick.buttonLeft.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.expressionsMouth2shut)
music.playSoundEffect(sounds.animalsCatPurr)
})
brick.buttonRight.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.expressionsMouth1open)
music.playSoundEffect(sounds.animalsDogBark1)
})
brick.buttonUp.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.objectsBoom)
music.playSoundEffect(sounds.animalsElephantCall)
})
brick.buttonDown.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.objectsPirate)
music.playSoundEffect(sounds.animalsSnakeHiss)
})
2018-06-12 15:46:44 +02:00
brick.showString("Guess the animal", 0)
2018-04-04 02:55:15 +02:00
```
## Step 10
2018-04-17 01:15:58 +02:00
Now, plug your EV3 Brick into the computer with the USB cable, and click the **Download** button at the bottom of your screen. Follow the directions to save your program to the brick.
2018-04-06 02:32:32 +02:00
Test your program with a friend by pressing the right, left, up, and down buttons on your brick. Have your friend guess what animal it is!