Lessons fixes (#1609)
* fixing a bunch of lessons * more fixes * more fixes * more cleanup * Additional fixes
This commit is contained in:
@ -15,7 +15,7 @@ input.onButtonPressed(Button.A, () => {
|
||||
newAction();
|
||||
}
|
||||
})
|
||||
input.onLogoDown(() => {
|
||||
input.onGesture(Gesture.LogoDown, function () {
|
||||
if (action == 1) {
|
||||
game.addScore(1);
|
||||
newAction();
|
||||
@ -36,13 +36,13 @@ input.onButtonPressed(Button.B, () => {
|
||||
|
||||
## Challenge 1
|
||||
|
||||
Now let's add some more types of instructions for the player to follow. Let's add `PRESS PIN 0`.
|
||||
Change the global variable `action` to `math->random(4)` so that we can add a new **IF** statement that checks if `action=3`. If it does, display instructions to press pin 0.
|
||||
Now let's add some more types of instructions for the player to follow. Let's add `"PRESS PIN 0"`.
|
||||
Change the global variable `action` to `math.randomRange(0, 3)` so that we can add a new **IF** statement that checks if `action == 3`. If it does, display instructions to press pin 0.
|
||||
|
||||
```typescript
|
||||
let action = 0;
|
||||
export function newAction() {
|
||||
action = Math.randomRange(0, 4)
|
||||
action = Math.randomRange(0, 3)
|
||||
if (action == 0) {
|
||||
basic.showString("PUSH A", 150) // ***
|
||||
}
|
||||
@ -60,7 +60,7 @@ export function newAction() {
|
||||
|
||||
## Challenge 2
|
||||
|
||||
Now let's implement `PRESS PIN 0` in the main. Create a condition of `input->on pin pressed("P0")` that will add one to the score and calls the method `new action`.
|
||||
Now let's implement `PRESS PIN 0` in the main. Create a condition in an `input.onPinPressed` event that, whet pin `P0` is pressed, will add one to the score and then calls the `newAction` function.
|
||||
|
||||
```typescript
|
||||
let action = 0;
|
||||
|
@ -21,7 +21,7 @@ let action = Math.randomRange(0, 3)
|
||||
```blocks
|
||||
let action = Math.randomRange(0, 3)
|
||||
if (action == 0) {
|
||||
basic.showString("PUSH A", 150)
|
||||
basic.showString("PUSH A")
|
||||
}
|
||||
```
|
||||
|
||||
@ -41,14 +41,14 @@ input.onButtonPressed(Button.A, () => {
|
||||
```blocks
|
||||
let action = Math.randomRange(0, 3)
|
||||
if (action == 1) {
|
||||
basic.showString("LOGO DOWN", 150)
|
||||
basic.showString("LOGO DOWN")
|
||||
}
|
||||
```
|
||||
|
||||
## 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
|
||||
|
||||
```blocks
|
||||
input.onLogoDown(() => {
|
||||
input.onGesture(Gesture.LogoDown, function () {
|
||||
let action = Math.randomRange(0, 3)
|
||||
if (action == 1) {
|
||||
game.addScore(1)
|
||||
@ -61,14 +61,14 @@ input.onLogoDown(() => {
|
||||
```blocks
|
||||
let action = Math.randomRange(0, 3)
|
||||
if (action == 2) {
|
||||
basic.showString("SHAKE", 150)
|
||||
basic.showString("SHAKE")
|
||||
}
|
||||
```
|
||||
|
||||
## 7. Write the code that increments the score if the @boardname@ is shaken when the global variable called 'action' is equal to 2
|
||||
|
||||
```blocks
|
||||
input.onLogoDown(() => {
|
||||
input.onGesture(Gesture.LogoDown, function () {
|
||||
let action = Math.randomRange(0, 3)
|
||||
if (action == 1) {
|
||||
game.addScore(1)
|
||||
|
Reference in New Issue
Block a user