2018-01-06 07:04:18 +01:00
|
|
|
# Roaming Activity 2
|
|
|
|
|
|
|
|
```blocks
|
|
|
|
let drive: number[] = []
|
2018-01-31 17:28:00 +01:00
|
|
|
brick.buttonLeft.onEvent(ButtonEvent.Bumped, function () {
|
2018-01-06 07:04:18 +01:00
|
|
|
drive.push(1)
|
|
|
|
music.playSoundEffectUntilDone(sounds.systemClick)
|
|
|
|
})
|
2018-01-31 17:28:00 +01:00
|
|
|
brick.buttonRight.onEvent(ButtonEvent.Bumped, function () {
|
2018-01-06 07:04:18 +01:00
|
|
|
drive.push(3)
|
|
|
|
music.playSoundEffectUntilDone(sounds.systemClick)
|
|
|
|
})
|
2018-01-31 17:28:00 +01:00
|
|
|
brick.buttonUp.onEvent(ButtonEvent.Bumped, function () {
|
2018-01-06 07:04:18 +01:00
|
|
|
drive.push(4)
|
|
|
|
music.playSoundEffectUntilDone(sounds.systemClick)
|
|
|
|
})
|
2018-01-31 17:28:00 +01:00
|
|
|
brick.buttonDown.onEvent(ButtonEvent.Bumped, function () {
|
2018-01-06 07:04:18 +01:00
|
|
|
drive.push(5)
|
|
|
|
music.playSoundEffectUntilDone(sounds.systemClick)
|
|
|
|
})
|
2018-01-31 17:28:00 +01:00
|
|
|
brick.buttonEnter.pauseUntil(ButtonEvent.Bumped);
|
2018-02-15 01:05:31 +01:00
|
|
|
pause(1000)
|
2018-01-06 07:04:18 +01:00
|
|
|
music.playSoundEffectUntilDone(sounds.communicationGo)
|
|
|
|
for (let d of drive) {
|
|
|
|
if (d == 1) {
|
2018-01-19 01:43:16 +01:00
|
|
|
motors.largeC.setSpeed(50, 360, MoveUnit.Degrees)
|
2018-01-06 07:04:18 +01:00
|
|
|
} else if (d == 3) {
|
2018-01-19 01:43:16 +01:00
|
|
|
motors.largeB.setSpeed(50, 360, MoveUnit.Degrees)
|
2018-01-06 07:04:18 +01:00
|
|
|
} else if (d == 4) {
|
2018-01-19 01:43:16 +01:00
|
|
|
motors.largeBC.setSpeed(50, 360, MoveUnit.Degrees)
|
2018-01-06 07:04:18 +01:00
|
|
|
} else {
|
2018-01-19 01:43:16 +01:00
|
|
|
motors.largeBC.setSpeed(-50, 360, MoveUnit.Degrees)
|
2018-01-06 07:04:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
music.playSoundEffectUntilDone(sounds.communicationGameOver)
|
|
|
|
```
|