2.1.28, initiation update to PXT v5.28.24 (#54)
This commit is contained in:
committed by
Peli de Halleux
parent
38a964516e
commit
5c114a0c57
33
docs/reference/game/add-life.md
Normal file
33
docs/reference/game/add-life.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# add Life
|
||||
|
||||
Increase the number of lives remaining by some amount.
|
||||
|
||||
```sig
|
||||
game.addLife(0)
|
||||
```
|
||||
|
||||
The life count in the game is increased by the number of lives you say.
|
||||
|
||||
## Parameters
|
||||
|
||||
* **life**: a [number](/types/number) to add to the life count.
|
||||
|
||||
## Example #example
|
||||
|
||||
Add `20` more lives to the life count if the player's score reaches `10000` points.
|
||||
|
||||
```blocks
|
||||
let giveLives = true
|
||||
|
||||
if (game.score() > 9999) {
|
||||
if (giveLives) {
|
||||
game.addLife(20)
|
||||
giveLives = false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## See also #seealso
|
||||
|
||||
[set life](/reference/game/set-life),
|
||||
[remove life](/reference/game/remove-life)
|
||||
30
docs/reference/game/add-score.md
Normal file
30
docs/reference/game/add-score.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# add Score
|
||||
|
||||
Add more to the current 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 to increase the score.
|
||||
Press ``B`` to display the score and reset the score.
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
basic.showNumber(game.score())
|
||||
game.setScore(0)
|
||||
})
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
game.addScore(1)
|
||||
})
|
||||
```
|
||||
|
||||
### See Also
|
||||
|
||||
[score](/reference/game/score), [set score](/reference/game/set-score), [start countdown](/reference/game/start-countdown)
|
||||
@@ -5,11 +5,11 @@ Add the amount you say to the score for the game.
|
||||
```sig
|
||||
game.addScore(1)
|
||||
```
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* a [number](/reference/types/number) that means how much to add to the score. A negative number means to subtract from the score.
|
||||
* a [number](/types/number) that means how much to add to the score. A negative number means to subtract from the score.
|
||||
|
||||
### Examples
|
||||
## Examples
|
||||
|
||||
This program is a simple game.
|
||||
Press button ``A`` as much as possible.
|
||||
@@ -22,6 +22,6 @@ input.onButtonPressed(Button.A, () => {
|
||||
game.startCountdown(10000)
|
||||
```
|
||||
|
||||
### See Also
|
||||
## See Also
|
||||
|
||||
[score](/reference/game/score), [start countdown](/reference/game/start-countdown)
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
# Get Sprite Property
|
||||
|
||||
Change the kind of [number](/reference/types/number) you say for a [sprite](/reference/game/create-sprite).
|
||||
|
||||
```sig
|
||||
let item: game.LedSprite = null;
|
||||
item.set(LedSpriteProperty.X, 0);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
* the **sprite** you want to change
|
||||
* the kind of [number](/reference/types/number) you want to change for the sprite, like
|
||||
* ``x``, how far up or down the sprite is on the screen (`0`-`4`)
|
||||
* ``y``, how far left or right the sprite is on the screen (`0`-`4`)
|
||||
* ``direction``, which way the sprite is pointing (this works the same way as the [turn](/reference/game/turn) function)
|
||||
* ``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
|
||||
|
||||
This program makes a sprite on the left side of the screen,
|
||||
waits two seconds (2000 milliseconds),
|
||||
and then moves it to the middle of the screen.
|
||||
|
||||
```blocks
|
||||
let ball = game.createSprite(0, 2);
|
||||
basic.pause(2000);
|
||||
ball.change(LedSpriteProperty.X, 2);
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
[turn](/reference/game/turn),
|
||||
[brightness](/reference/led/brightness),
|
||||
[get sprite property](/reference/game/get-sprite-property),
|
||||
[set sprite property](/reference/game/set-sprite-property)
|
||||
35
docs/reference/game/change.md
Normal file
35
docs/reference/game/change.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# change (Sprite Property)
|
||||
|
||||
Change the kind of [number](/types/number) you say for a [sprite](/reference/game/create-sprite).
|
||||
|
||||
```sig
|
||||
game.createSprite(0,0).change(LedSpriteProperty.X, 0);
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
* **property**: the property of the **Sprite** you want to change, like:
|
||||
>* ``x`` - how far up or down the sprite is on the screen (`0`-`4`)
|
||||
>* ``y`` - how far left or right the sprite is on the screen (`0`-`4`)
|
||||
>* ``direction`` - which way the sprite is pointing (this works the same way as the [turn](/reference/game/turn) function)
|
||||
>* ``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
|
||||
|
||||
This program makes a sprite on the left side of the screen,
|
||||
waits two seconds (2000 milliseconds),
|
||||
and then moves it to the middle of the screen.
|
||||
|
||||
```blocks
|
||||
let ball = game.createSprite(0, 2);
|
||||
basic.pause(2000);
|
||||
ball.change(LedSpriteProperty.X, 2);
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[turn](/reference/game/turn),
|
||||
[brightness](/reference/led/brightness),
|
||||
[get sprite property](/reference/game/get),
|
||||
[set sprite property](/reference/game/set)
|
||||
@@ -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,25 @@ 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
|
||||
## Returns
|
||||
|
||||
* a new **LedSprite** at the location you say.
|
||||
|
||||
## ~ hint
|
||||
|
||||
Once the game engine is started, it will render the sprites to the screen and potentially override any kind of animation you are trying to show.
|
||||
Using [game pause](/reference/game/pause) and [game resume](/reference/game/resume) to disable and enable the game rendering loop.
|
||||
|
||||
## ~
|
||||
|
||||
## Example
|
||||
|
||||
This program starts a sprite in the middle of the screen.
|
||||
Next, the sprite turns toward the lower-right corner.
|
||||
@@ -29,9 +40,9 @@ item.turn(Direction.Right, 45);
|
||||
item.move(2);
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[move](/reference/game/move),
|
||||
[turn](/reference/game/turn),
|
||||
[touching](/reference/game/touching)
|
||||
[is-touching](/reference/game/is-touching)
|
||||
|
||||
|
||||
21
docs/reference/game/delete.md
Normal file
21
docs/reference/game/delete.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# delete
|
||||
|
||||
Delete a sprite from the game.
|
||||
|
||||
```sig
|
||||
game.createSprite(0,0).delete()
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
This program makes a sprite and shows the number of its brightness on the screen. Then, it deletes the sprite.
|
||||
|
||||
```blocks
|
||||
let ball = game.createSprite(0, 2);
|
||||
basic.showNumber(ball.get(LedSpriteProperty.Brightness));
|
||||
ball.delete();
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[create sprite](/reference/game/create-sprite)
|
||||
@@ -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),
|
||||
[change score by](/reference/game/change-score-by), [start countdown](/reference/game/start-countdown)
|
||||
[add score](/reference/game/add-score), [start countdown](/reference/game/start-countdown)
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
# Get Sprite Property
|
||||
|
||||
Find something out about a [sprite](/reference/game/create-sprite).
|
||||
|
||||
```sig
|
||||
let item: game.LedSprite = null;
|
||||
item.get(LedSpriteProperty.X);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
* the **sprite** you want to know something about
|
||||
* the kind of [number](/reference/types/number) you want to know about the sprite, like
|
||||
* ``x``, how far up or down the sprite is on the screen (`0`-`4`)
|
||||
* ``y``, how far left or right the sprite is on the screen (`0`-`4`)
|
||||
* ``direction``, which way the sprite is pointing (this works the same way as the [turn](/reference/game/turn) function)
|
||||
* ``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
|
||||
|
||||
The [number](/reference/types/number) you asked for.
|
||||
|
||||
### Example
|
||||
|
||||
This program makes a sprite and shows the number of its brightness on the screen.
|
||||
|
||||
```blocks
|
||||
let ball = game.createSprite(0, 2);
|
||||
basic.showNumber(ball.get(LedSpriteProperty.Brightness));
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
[turn](/reference/game/turn),
|
||||
[brightness](/reference/led/brightness),
|
||||
[change sprite property](/reference/game/change-sprite-property),
|
||||
[set sprite property](/reference/game/set-sprite-property)
|
||||
|
||||
37
docs/reference/game/get.md
Normal file
37
docs/reference/game/get.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# get (Sprite Property)
|
||||
|
||||
Find something out about a [sprite](/reference/game/create-sprite).
|
||||
|
||||
```sig
|
||||
game.createSprite(0,0).get(LedSpriteProperty.X);
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
* **property**: the property of the **Sprite** you want to know about, like:
|
||||
>* ``x`` - how far up or down the sprite is on the screen (`0`-`4`)
|
||||
>* ``y`` - how far left or right the sprite is on the screen (`0`-`4`)
|
||||
>* ``direction`` - which way the sprite is pointing (this works the same way as the [turn](/reference/game/turn) function)
|
||||
>* ``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
|
||||
|
||||
* a [number](/types/number) value of the property you asked for.
|
||||
|
||||
## Example
|
||||
|
||||
This program makes a sprite and shows the number of its brightness on the screen.
|
||||
|
||||
```blocks
|
||||
let ball = game.createSprite(0, 2);
|
||||
basic.showNumber(ball.get(LedSpriteProperty.Brightness));
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[turn](/reference/game/turn),
|
||||
[brightness](/reference/led/brightness),
|
||||
[change sprite property](/reference/game/change),
|
||||
[set sprite property](/reference/game/set)
|
||||
|
||||
@@ -4,15 +4,14 @@ Make a [sprite](/reference/game/create-sprite) on the edge of the
|
||||
[LED screen](/device/screen) bounce away.
|
||||
|
||||
```sig
|
||||
let item = game.createSprite(0, 2);
|
||||
item.ifOnEdgeBounce();
|
||||
game.createSprite(0, 2).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,8 +26,8 @@ input.onButtonPressed(Button.B, () => {
|
||||
});
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[create sprite](/reference/game/create-sprite),
|
||||
[touching](/reference/game/touching),
|
||||
[touching edge](/reference/game/touching-edge)
|
||||
[is touching](/reference/game/is-touching),
|
||||
[is touching edge](/reference/game/is-touching-edge)
|
||||
|
||||
33
docs/reference/game/is-deleted.md
Normal file
33
docs/reference/game/is-deleted.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# Is Deleted
|
||||
|
||||
Find out if the sprite is deleted from the game engine or not.
|
||||
|
||||
```sig
|
||||
game.createSprite(0,0).isDeleted()
|
||||
```
|
||||
|
||||
## Returns
|
||||
|
||||
* a [boolean](/types/boolean) value that is `true` if the sprite is deleted from the game engine or `false` if not.
|
||||
|
||||
## Example
|
||||
|
||||
This game has 5 sprites initially. After 1 second, the third sprite is deleted and all remaining sprites are moved by 1.
|
||||
|
||||
```blocks
|
||||
let sprites: game.LedSprite[] = []
|
||||
for (let i = 0; i <= 4; i++) {
|
||||
sprites.push(game.createSprite(0, i))
|
||||
}
|
||||
basic.pause(1000)
|
||||
sprites[2].delete()
|
||||
for (let sprite of sprites) {
|
||||
if (!(sprite.isDeleted())) {
|
||||
sprite.move(1)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[delete sprite](/reference/game/delete)
|
||||
25
docs/reference/game/is-game-over.md
Normal file
25
docs/reference/game/is-game-over.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# is Game Over
|
||||
|
||||
Find out if the game is over or not.
|
||||
|
||||
```sig
|
||||
game.isGameOver()
|
||||
```
|
||||
|
||||
## Returns
|
||||
|
||||
* a [boolean](/types/boolean) value that is `true` if the game is over or `false` if not.
|
||||
# Example
|
||||
|
||||
Be kind and give the player some points for trying.
|
||||
|
||||
```blocks
|
||||
if (game.isGameOver() && game.score() < 10) {
|
||||
game.addScore(10 - game.score())
|
||||
}
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[is running](/reference/game/is-running),
|
||||
[is paused](/reference/game/is-paused)
|
||||
28
docs/reference/game/is-paused.md
Normal file
28
docs/reference/game/is-paused.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# is Paused
|
||||
|
||||
Find out if the game is paused or not.
|
||||
|
||||
```sig
|
||||
game.isPaused()
|
||||
```
|
||||
|
||||
## Returns
|
||||
|
||||
* a [boolean](/types/boolean) value that is `true` if the game is paused or `false` if not.
|
||||
|
||||
## Example
|
||||
|
||||
Resume the game if it's paused and button **B** is pressed.
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.B, function () {
|
||||
if (game.isPaused()) {
|
||||
game.resume()
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[is running](/reference/game/is-running),
|
||||
[is game over](/reference/game/is-game-over)
|
||||
28
docs/reference/game/is-running.md
Normal file
28
docs/reference/game/is-running.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# is Running
|
||||
|
||||
Find out if the game is currently running or not.
|
||||
|
||||
```sig
|
||||
game.isRunning()
|
||||
```
|
||||
|
||||
## Returns
|
||||
|
||||
* a [boolean](/types/boolean) value that is `true` if the game is running or `false` if not.
|
||||
|
||||
## Example
|
||||
|
||||
If the game is currently running, end the game if button **B** is pressed.
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.B, function () {
|
||||
if (game.isRunning()) {
|
||||
game.gameOver()
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[is paused](/reference/game/is-paused),
|
||||
[is game over](/reference/game/is-game-over)
|
||||
@@ -6,19 +6,18 @@ Sprites are touching the edge if they overlap with an LED on the edge
|
||||
of the screen.
|
||||
|
||||
```sig
|
||||
let item: game.LedSprite = null;
|
||||
item.isTouchingEdge();
|
||||
game.createSprite(0, 2).isTouchingEdge();
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* a **sprite** that might be touching the edge of the screen
|
||||
* a **sprite** that might be touching the edge of the screen.
|
||||
|
||||
### Returns
|
||||
## Returns
|
||||
|
||||
`true` if the sprite is touching the edge of the screen
|
||||
* `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,8 +32,8 @@ if (item.isTouchingEdge()) {
|
||||
}
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[create sprite](/reference/game/create-sprite),
|
||||
[touching](/reference/game/touching),
|
||||
[is touching](/reference/game/is-touching),
|
||||
[if on edge, bounce](/reference/game/if-on-edge-bounce)
|
||||
@@ -5,20 +5,18 @@ Find whether the sprite is touching another sprite you say.
|
||||
Sprites are touching if they share the same LED.
|
||||
|
||||
```sig
|
||||
let item: game.LedSprite = null;
|
||||
item.isTouching(null);
|
||||
game.createSprite(0, 2).isTouching(null);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* a **sprite** you are checking
|
||||
* another **sprite** that might be touching the one you are checking
|
||||
* another **sprite** that might be touching the one you are checking.
|
||||
|
||||
### Returns
|
||||
## Returns
|
||||
|
||||
`true` if the two sprites are touching.
|
||||
* `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,8 +32,8 @@ if (matter.isTouching(antimatter)) {
|
||||
}
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[create sprite](/reference/game/create-sprite),
|
||||
[touching edge](/reference/game/touching-edge),
|
||||
[is touching edge](/reference/game/is-touching-edge),
|
||||
[if on edge, bounce](/reference/game/if-on-edge-bounce)
|
||||
@@ -3,15 +3,14 @@
|
||||
Move the sprite the number of LEDs you say.
|
||||
|
||||
```sig
|
||||
let item: game.LedSprite = null;
|
||||
item.move(1);
|
||||
game.createSprite(0, 2).move(1);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* a [number](/reference/types/number) that means how many LEDs the sprite should move
|
||||
* **leds**: 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 +22,7 @@ item.turn(Direction.Right, 45);
|
||||
item.move(2);
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[turn](/reference/game/turn),
|
||||
[create sprite](/reference/game/create-sprite)
|
||||
|
||||
11
docs/reference/game/pause.md
Normal file
11
docs/reference/game/pause.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# Pause
|
||||
|
||||
Pauses the game rendering engine to allow other animations on the screen.
|
||||
|
||||
```sig
|
||||
game.pause()
|
||||
```
|
||||
|
||||
### See Also
|
||||
|
||||
[resume](/reference/game/resume)
|
||||
33
docs/reference/game/remove-life.md
Normal file
33
docs/reference/game/remove-life.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# remove Life
|
||||
|
||||
Decrease the number of lives remaining by some amount.
|
||||
|
||||
```sig
|
||||
game.removeLife(0)
|
||||
```
|
||||
|
||||
The life count in the game is decreased by the number of lives you say. If the life count reaches `0` when these lives are removed, then the game is over.
|
||||
|
||||
## Parameters
|
||||
|
||||
* **life**: a [number](/types/number) to remove from the count.
|
||||
|
||||
## Example #example
|
||||
|
||||
Take away `20` lives count if the player's score reaches `10000` points.
|
||||
|
||||
```blocks
|
||||
let giveLives = true
|
||||
|
||||
if (game.score() > 9999) {
|
||||
if (giveLives) {
|
||||
game.removeLife(20)
|
||||
giveLives = false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## See also #seealso
|
||||
|
||||
[set life](/reference/game/set-life),
|
||||
[add life](/reference/game/add-life)
|
||||
11
docs/reference/game/resume.md
Normal file
11
docs/reference/game/resume.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# Resume
|
||||
|
||||
Resumes the game rendering engine after a pause.
|
||||
|
||||
```sig
|
||||
game.resume()
|
||||
```
|
||||
|
||||
### See Also
|
||||
|
||||
[pause](/reference/game/pause)
|
||||
@@ -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)
|
||||
|
||||
26
docs/reference/game/set-life.md
Normal file
26
docs/reference/game/set-life.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# set Life
|
||||
|
||||
Set the game life count to this amount.
|
||||
|
||||
```sig
|
||||
game.setLife(0)
|
||||
```
|
||||
|
||||
Your program has a life counter which you can set to record the number of lives remaining for a player in your game. If you set the life count to `0` or less, the game ends.
|
||||
|
||||
## Parameters
|
||||
|
||||
* **value**: a [number](/types/number) to set the life count to.
|
||||
|
||||
## Example #example
|
||||
|
||||
Set the player life count to `9` lives before starting the game.
|
||||
|
||||
```blocks
|
||||
game.setLife(9)
|
||||
```
|
||||
|
||||
## See also #seealso
|
||||
|
||||
[add life](/reference/game/add-life),
|
||||
[remove life](/reference/game/remove-life)
|
||||
@@ -5,11 +5,11 @@ Sets the current score.
|
||||
```sig
|
||||
game.setScore(1)
|
||||
```
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* a [number](/reference/types/number) that represents the new score.
|
||||
* 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), [start countdown](/reference/game/start-countdown)
|
||||
[score](/reference/game/score), [add score](/reference/game/add-score), [start countdown](/reference/game/start-countdown)
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
# Set Sprite Property
|
||||
|
||||
Make a [sprite](/reference/game/create-sprite) store the kind of [number](/reference/types/number) you say.
|
||||
|
||||
```sig
|
||||
let item: game.LedSprite = null;
|
||||
item.set(LedSpriteProperty.X, 0);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
* the **sprite** you want to make store the number you say
|
||||
* the kind of [number](/reference/types/number) you want to store in the sprite, like
|
||||
* ``x``, how far up or down the sprite is on the screen (`0`-`4`)
|
||||
* ``y``, how far left or right the sprite is on the screen (`0`-`4`)
|
||||
* ``direction``, which way the sprite is pointing (this works the same way as the [turn](/reference/game/turn) function)
|
||||
* ``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
|
||||
|
||||
This program makes a sprite on the left side of the screen,
|
||||
waits two seconds (2000 milliseconds),
|
||||
and then moves it to the right side of the screen.
|
||||
|
||||
```blocks
|
||||
let ball = game.createSprite(0, 2);
|
||||
basic.pause(2000);
|
||||
ball.set(LedSpriteProperty.X, 4);
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
[turn](/reference/game/turn),
|
||||
[brightness](/reference/led/brightness),
|
||||
[change sprite property](/reference/game/change-sprite-property),
|
||||
[get sprite property](/reference/game/get-sprite-property)
|
||||
35
docs/reference/game/set.md
Normal file
35
docs/reference/game/set.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# set (Sprite Property)
|
||||
|
||||
Make a [sprite](/reference/game/create-sprite) store the kind of [number](/types/number) you say.
|
||||
|
||||
```sig
|
||||
game.createSprite(0,0).set(LedSpriteProperty.X, 0);
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
* **property**: the property of the **Sprite** you want to store a value for, like:
|
||||
>* ``x`` - how far up or down the sprite is on the screen (`0`-`4`)
|
||||
>* ``y`` - how far left or right the sprite is on the screen (`0`-`4`)
|
||||
>* ``direction`` - which way the sprite is pointing (this works the same way as the [turn](/reference/game/turn) function)
|
||||
>* ``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
|
||||
|
||||
This program makes a sprite on the left side of the screen,
|
||||
waits two seconds (2000 milliseconds),
|
||||
and then moves it to the right side of the screen.
|
||||
|
||||
```blocks
|
||||
let ball = game.createSprite(0, 2);
|
||||
basic.pause(2000);
|
||||
ball.set(LedSpriteProperty.X, 4);
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[turn](/reference/game/turn),
|
||||
[brightness](/reference/led/brightness),
|
||||
[change sprite property](/reference/game/change),
|
||||
[get sprite property](/reference/game/get)
|
||||
@@ -6,11 +6,11 @@ Start counting down time from the number of milliseconds you say.
|
||||
game.startCountdown(1000)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* ``ms`` is a [number](/reference/types/number) that says how many milliseconds to count down (one second is 1000 milliseconds)
|
||||
* ``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), [change score by](/reference/game/change-score-by)
|
||||
[score](/reference/game/score), [add score](/reference/game/add-score)
|
||||
|
||||
|
||||
@@ -3,17 +3,16 @@
|
||||
Turn the sprite as much as you say in the direction you say.
|
||||
|
||||
```sig
|
||||
let item: game.LedSprite = null;
|
||||
item.turn(Direction.Right, 45);
|
||||
game.createSprite(0, 2).turn(Direction.Right, 45);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* a choice whether the sprite should turn **left** or **right**
|
||||
* a [number](/reference/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.
|
||||
* **direction**: a choice whether the sprite should turn **left** or **right**
|
||||
* **degrees**: a [number](/types/number) degrees of angle that the sprite should turn.
|
||||
A straight left or right turn is 90 degrees.
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
|
||||
This program starts a sprite in the middle of the screen.
|
||||
@@ -26,7 +25,7 @@ item.turn(Direction.Right, 45);
|
||||
item.move(2);
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
|
||||
[move](/reference/game/move),
|
||||
|
||||
Reference in New Issue
Block a user