diff --git a/docs/coding.md b/docs/coding.md index abb9cdd3..67f75749 100644 --- a/docs/coding.md +++ b/docs/coding.md @@ -152,4 +152,19 @@ "url":"/coding/cruise-control-3", "cardType": "example" }] -``` \ No newline at end of file +``` + +## Roaming + +```codecard +[{ + "name": "Roaming 1", + "description": "Activity 1", + "url":"/coding/roaming-1", + "cardType": "example" +}, { + "name": "Roaming 2", + "description": "Activity 2", + "url":"/coding/roaming-2", + "cardType": "example" +}, { diff --git a/docs/coding/roaming-1.md b/docs/coding/roaming-1.md new file mode 100644 index 00000000..8d622159 --- /dev/null +++ b/docs/coding/roaming-1.md @@ -0,0 +1,36 @@ +# Roaming Activity 1 + +```blocks +let drive: number[] = [] +brick.buttonLeft.onEvent(ButtonEvent.Click, function () { + drive.push(1) +}) +brick.buttonRight.onEvent(ButtonEvent.Click, function () { + drive.push(3) +}) +brick.buttonUp.onEvent(ButtonEvent.Click, function () { + drive.push(4) +}) +brick.buttonDown.onEvent(ButtonEvent.Click, function () { + drive.push(5) +}) +pauseUntil(() => drive.length >= 5) +loops.pause(1000) +music.playSoundEffectUntilDone(sounds.communicationGo) +for (let d of drive) { + if (d == 1) { + motors.largeC.setSpeedFor(50, 360, MoveUnit.Degrees) + motors.largeC.pauseUntilReady() + } else if (d == 3) { + motors.largeB.setSpeedFor(50, 360, MoveUnit.Degrees) + motors.largeB.pauseUntilReady() + } else if (d == 4) { + motors.largeBC.setSpeedFor(50, 360, MoveUnit.Degrees) + motors.largeBC.pauseUntilReady() + } else { + motors.largeBC.setSpeedFor(-50, 360, MoveUnit.Degrees) + motors.largeBC.pauseUntilReady() + } +} +music.playSoundEffectUntilDone(sounds.communicationGameOver) +``` \ No newline at end of file diff --git a/docs/coding/roaming-2.md b/docs/coding/roaming-2.md new file mode 100644 index 00000000..dcae460f --- /dev/null +++ b/docs/coding/roaming-2.md @@ -0,0 +1,40 @@ +# Roaming Activity 2 + +```blocks +let drive: number[] = [] +brick.buttonLeft.onEvent(ButtonEvent.Click, function () { + drive.push(1) + music.playSoundEffectUntilDone(sounds.systemClick) +}) +brick.buttonRight.onEvent(ButtonEvent.Click, function () { + drive.push(3) + music.playSoundEffectUntilDone(sounds.systemClick) +}) +brick.buttonUp.onEvent(ButtonEvent.Click, function () { + drive.push(4) + music.playSoundEffectUntilDone(sounds.systemClick) +}) +brick.buttonDown.onEvent(ButtonEvent.Click, function () { + drive.push(5) + music.playSoundEffectUntilDone(sounds.systemClick) +}) +brick.buttonEnter.pauseUntil(ButtonEvent.Click); +loops.pause(1000) +music.playSoundEffectUntilDone(sounds.communicationGo) +for (let d of drive) { + if (d == 1) { + motors.largeC.setSpeedFor(50, 360, MoveUnit.Degrees) + motors.largeC.pauseUntilReady() + } else if (d == 3) { + motors.largeB.setSpeedFor(50, 360, MoveUnit.Degrees) + motors.largeB.pauseUntilReady() + } else if (d == 4) { + motors.largeBC.setSpeedFor(50, 360, MoveUnit.Degrees) + motors.largeBC.pauseUntilReady() + } else { + motors.largeBC.setSpeedFor(-50, 360, MoveUnit.Degrees) + motors.largeBC.pauseUntilReady() + } +} +music.playSoundEffectUntilDone(sounds.communicationGameOver) +``` \ No newline at end of file