27
docs/reference/game/change-score-by.md
Normal file
27
docs/reference/game/change-score-by.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Change Score By
|
||||
|
||||
Add the amount you say to the score for the game.
|
||||
|
||||
```sig
|
||||
game.addScore(1)
|
||||
```
|
||||
## Parameters
|
||||
|
||||
* a [number](/types/number) that means how much to add to the score. A negative number means to subtract from the score.
|
||||
|
||||
## Examples
|
||||
|
||||
This program is a simple game.
|
||||
Press button ``A`` as much as possible.
|
||||
At the end of 10 seconds, the program will show your score.
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
game.addScore(1)
|
||||
})
|
||||
game.startCountdown(10000)
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
[score](/reference/game/score), [start countdown](/reference/game/start-countdown)
|
@ -7,7 +7,7 @@ let item: game.LedSprite = null;
|
||||
item.change(LedSpriteProperty.X, 0);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* the **sprite** you want to change
|
||||
* the kind of [number](/types/number) you want to change for the sprite, like
|
||||
@ -17,7 +17,7 @@ item.change(LedSpriteProperty.X, 0);
|
||||
* ``brightness``, how bright the LED sprite is (this works the same way as the [brightness](/reference/led/brightness) function)
|
||||
* ``blink``, how fast the sprite is blinking (the bigger the number is, the faster the sprite is blinking)
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
This program makes a sprite on the left side of the screen,
|
||||
waits two seconds (2000 milliseconds),
|
||||
@ -29,7 +29,7 @@ basic.pause(2000);
|
||||
ball.change(LedSpriteProperty.X, 2);
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[turn](/reference/game/turn),
|
||||
[brightness](/reference/led/brightness),
|
||||
|
@ -4,17 +4,17 @@ The clear function for images.
|
||||
|
||||
Turn off all the pixels in an [Image](/reference/images/image).
|
||||
|
||||
### JavaScript
|
||||
## JavaScript
|
||||
|
||||
```sig
|
||||
export function clear(img: micro_bit.Image)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* none
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
The following example turns off the pixels of `img` when the A input button is pressed:
|
||||
|
||||
@ -33,7 +33,7 @@ input.onButtonPressed(Button.A, () => {
|
||||
})
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[Image](/reference/images/image), [show animation](/reference/basic/show-animation), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image), [create image](/reference/images/create-image)
|
||||
|
||||
|
@ -10,14 +10,14 @@ into another sprite.
|
||||
game.createSprite(2, 2);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* ``x``: The left-to-right place on the LED screen where the sprite will start out.
|
||||
* ``y``: The top-to-bottom place on the LED screen where the sprite will start out.
|
||||
|
||||
`0` and `4` mean the edges of the screen, and `2` means in the middle.
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
This program starts a sprite in the middle of the screen.
|
||||
Next, the sprite turns toward the lower-right corner.
|
||||
@ -29,7 +29,7 @@ item.turn(Direction.Right, 45);
|
||||
item.move(2);
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[move](/reference/game/move),
|
||||
[turn](/reference/game/turn),
|
||||
|
@ -6,7 +6,7 @@ End the game and show the score.
|
||||
game.gameOver();
|
||||
```
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
This program asks you to pick a button.
|
||||
If you press button `A`, the program says `YOU WIN!`.
|
||||
@ -22,7 +22,7 @@ input.onButtonPressed(Button.B, () => {
|
||||
});
|
||||
```
|
||||
|
||||
### See Also
|
||||
## See Also
|
||||
|
||||
[score](/reference/game/score),
|
||||
[add score](/reference/game/add-score), [start countdown](/reference/game/start-countdown)
|
||||
|
@ -7,7 +7,7 @@ let item: game.LedSprite = null;
|
||||
item.get(LedSpriteProperty.X);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* the **sprite** you want to know something about
|
||||
* the kind of [number](/types/number) you want to know about the sprite, like
|
||||
@ -17,11 +17,11 @@ item.get(LedSpriteProperty.X);
|
||||
* ``brightness``, how bright the LED sprite is (this works the same way as the [brightness](/reference/led/brightness) function)
|
||||
* ``blink``, how fast the sprite is blinking (the bigger the number is, the faster the sprite is blinking)
|
||||
|
||||
### Returns
|
||||
## Returns
|
||||
|
||||
The [number](/types/number) you asked for.
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
This program makes a sprite and shows the number of its brightness on the screen.
|
||||
|
||||
@ -30,7 +30,7 @@ let ball = game.createSprite(0, 2);
|
||||
basic.showNumber(ball.get(LedSpriteProperty.Brightness));
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[turn](/reference/game/turn),
|
||||
[brightness](/reference/led/brightness),
|
||||
|
@ -8,11 +8,11 @@ let item = game.createSprite(0, 2);
|
||||
item.ifOnEdgeBounce();
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* a **sprite** that might be on the edge of the LED screen.
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
This program makes a sprite on the right edge of the screen with a
|
||||
direction of 90 degrees, and bounces it so it has a direction of -90
|
||||
@ -27,7 +27,7 @@ input.onButtonPressed(Button.B, () => {
|
||||
});
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[create sprite](/reference/game/create-sprite),
|
||||
[is touching](/reference/game/is-touching),
|
||||
|
@ -10,15 +10,15 @@ let item: game.LedSprite = null;
|
||||
item.isTouchingEdge();
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* a **sprite** that might be touching the edge of the screen
|
||||
|
||||
### Returns
|
||||
## Returns
|
||||
|
||||
`true` if the sprite is touching the edge of the screen
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
This program makes a sprite in the middle of the left edge of the LED screen.
|
||||
Then it says `EDGY!` if it's on the edge (which it is!), and `SAFE!` if it's
|
||||
@ -33,7 +33,7 @@ if (item.isTouchingEdge()) {
|
||||
}
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[create sprite](/reference/game/create-sprite),
|
||||
[is touching](/reference/game/is-touching),
|
||||
|
@ -9,16 +9,16 @@ let item: game.LedSprite = null;
|
||||
item.isTouching(null);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* a **sprite** you are checking
|
||||
* another **sprite** that might be touching the one you are checking
|
||||
|
||||
### Returns
|
||||
## Returns
|
||||
|
||||
`true` if the two sprites are touching.
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
This program creates two sprites called ``matter`` and ``antimatter``,
|
||||
and then checks whether they are touching. If they are, there is an
|
||||
@ -34,7 +34,7 @@ if (matter.isTouching(antimatter)) {
|
||||
}
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[create sprite](/reference/game/create-sprite),
|
||||
[is touching edge](/reference/game/is-touching-edge),
|
||||
|
@ -7,11 +7,11 @@ let item: game.LedSprite = null;
|
||||
item.move(1);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* a [number](/types/number) that means how many LEDs the sprite should move
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
This program starts a sprite in the middle of the screen.
|
||||
Next, the sprite turns toward the lower-right corner.
|
||||
@ -23,7 +23,7 @@ item.turn(Direction.Right, 45);
|
||||
item.move(2);
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[turn](/reference/game/turn),
|
||||
[create sprite](/reference/game/create-sprite)
|
||||
|
@ -6,7 +6,7 @@ Find the number of points scored in your game.
|
||||
game.score()
|
||||
```
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
This program adds one point to your score every time you press button
|
||||
`A`, and shows an animation. Then it waits 500 milliseconds (half a
|
||||
@ -20,6 +20,6 @@ input.onButtonPressed(Button.A, () => {
|
||||
});
|
||||
```
|
||||
|
||||
### See Also
|
||||
## See Also
|
||||
|
||||
[change score by](/reference/game/score), [start countdown](/reference/game/start-countdown)
|
||||
|
@ -5,11 +5,11 @@ Sets the current score.
|
||||
```sig
|
||||
game.setScore(1)
|
||||
```
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* a [number](/types/number) that represents the new score.
|
||||
|
||||
### Examples
|
||||
## Examples
|
||||
|
||||
This program is a simple game.
|
||||
Press button ``A`` as much as possible to increase the score.
|
||||
@ -25,6 +25,6 @@ input.onButtonPressed(Button.A, () => {
|
||||
})
|
||||
```
|
||||
|
||||
### See Also
|
||||
## See Also
|
||||
|
||||
[score](/reference/game/score), [add score](/reference/game/add-score), [start countdown](/reference/game/start-countdown)
|
||||
|
@ -7,7 +7,7 @@ let item: game.LedSprite = null;
|
||||
item.set(LedSpriteProperty.X, 0);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* the **sprite** you want to make store the number you say
|
||||
* the kind of [number](/types/number) you want to store in the sprite, like
|
||||
@ -17,7 +17,7 @@ item.set(LedSpriteProperty.X, 0);
|
||||
* ``brightness``, how bright the LED sprite is (this works the same way as the [brightness](/reference/led/brightness) function)
|
||||
* ``blink``, how fast the sprite is blinking (the bigger the number is, the faster the sprite is blinking)
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
This program makes a sprite on the left side of the screen,
|
||||
waits two seconds (2000 milliseconds),
|
||||
@ -29,7 +29,7 @@ basic.pause(2000);
|
||||
ball.set(LedSpriteProperty.X, 4);
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[turn](/reference/game/turn),
|
||||
[brightness](/reference/led/brightness),
|
||||
|
@ -6,11 +6,11 @@ Start counting down time from the number of milliseconds you say.
|
||||
game.startCountdown(1000)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* ``ms`` is a [number](/types/number) that says how many milliseconds to count down (one second is 1000 milliseconds)
|
||||
|
||||
### Examples
|
||||
## Examples
|
||||
|
||||
This program is a simple game.
|
||||
Press button ``A`` as much as possible.
|
||||
@ -23,7 +23,7 @@ input.onButtonPressed(Button.A, () => {
|
||||
game.startCountdown(10000)
|
||||
```
|
||||
|
||||
### See Also
|
||||
## See Also
|
||||
|
||||
[score](/reference/game/score), [add score](/reference/game/add-score)
|
||||
|
||||
|
@ -7,13 +7,13 @@ let item: game.LedSprite = null;
|
||||
item.turn(Direction.Right, 45);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* a choice whether the sprite should turn **left** or **right**
|
||||
* a [number](/types/number) that means how much the sprite should turn.
|
||||
This number is in **degrees**, so a straight left or right turn is 90 degrees.
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
|
||||
This program starts a sprite in the middle of the screen.
|
||||
@ -26,7 +26,7 @@ item.turn(Direction.Right, 45);
|
||||
item.move(2);
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
|
||||
[move](/reference/game/move),
|
||||
|
Reference in New Issue
Block a user