Updates for V4 (#197)
* update yotta defaults for 16kb devices * refactor deprecated blocks * updates for button events * update button events * update refference * update docs * update docs * update button event blocks * update docs * update block id
This commit is contained in:
@ -1,19 +1,23 @@
|
||||
# change (Sprite Property)
|
||||
|
||||
Change the kind of [number](/types/number) you say for a [sprite](/reference/game/create-sprite).
|
||||
Change a value for a [sprite](/reference/game/create-sprite) property by some amount.
|
||||
|
||||
```sig
|
||||
game.createSprite(0,0).change(LedSpriteProperty.X, 0);
|
||||
```
|
||||
|
||||
The value of a sprite propery is changed by using either a positive or negative number. Giving `1` will increase a property value by `1` and giving a `-1` will decrease it by `1`.
|
||||
|
||||
## 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)
|
||||
>* ``x`` - the change in horizontal location to set the sprite at on the LED screen (`0`-`4`)
|
||||
>* ``y`` - the change vertical location to set the sprite at on the LED screen (`0`-`4`)
|
||||
>* ``direction`` - the change of direction in degrees for the sprite to go when the next [move](/reference/game/move) happens. Direction degree range is from `-180` to `180`.
|
||||
>* ``brightness`` - the change in brightness for the LED sprite. Completely dark is `0` and very bright is `255`.
|
||||
>* ``blink`` - the change in how fast the sprite is will blink on and off. The blink rate is in milliseconds.
|
||||
|
||||
* **value**: a [number](/types/number) value that is the amount of change for the property.
|
||||
|
||||
## Example
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# get (Sprite Property)
|
||||
|
||||
Find something out about a [sprite](/reference/game/create-sprite).
|
||||
Get a value for a [sprite](/reference/game/create-sprite) property.
|
||||
|
||||
```sig
|
||||
game.createSprite(0,0).get(LedSpriteProperty.X);
|
||||
@ -9,11 +9,11 @@ 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)
|
||||
>* ``x`` - the horizontal location to set the sprite at on the LED screen (`0`-`4`)
|
||||
>* ``y`` - the vertical location to set the sprite at on the LED screen (`0`-`4`)
|
||||
>* ``direction`` - the direction in degrees for the sprite to go when the next [move](/reference/game/move) happens. The degree range is from `-180` to `180`.
|
||||
>* ``brightness`` - how bright the LED sprite is. Completely dark is `0` and very bright is `255`.
|
||||
>* ``blink`` - how fast the sprite is will blink on and off. The blink rate is in milliseconds.
|
||||
|
||||
## Returns
|
||||
|
||||
|
@ -15,7 +15,7 @@ game.isRunning()
|
||||
If the game is currently running, end the game if button **B** is pressed.
|
||||
|
||||
```blocks
|
||||
input.onButtonEvent(Button.B, ButtonEvent.Click, function () {
|
||||
input.onButtonEvent(Button.B, input.buttonEventClick(), function () {
|
||||
if (game.isRunning()) {
|
||||
game.gameOver()
|
||||
}
|
||||
|
@ -16,11 +16,11 @@ Press button ``A`` as much as possible to increase the score.
|
||||
Press ``B`` to display the score and reset the score.
|
||||
|
||||
```blocks
|
||||
input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
|
||||
input.onButtonEvent(Button.B, input.buttonEventClick(), () => {
|
||||
basic.showNumber(game.score())
|
||||
game.setScore(0)
|
||||
})
|
||||
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
|
||||
input.onButtonEvent(Button.A, input.buttonEventClick(), () => {
|
||||
game.addScore(1)
|
||||
})
|
||||
```
|
||||
|
@ -1,6 +1,6 @@
|
||||
# set (Sprite Property)
|
||||
|
||||
Make a [sprite](/reference/game/create-sprite) store the kind of [number](/types/number) you say.
|
||||
Set a value for a [sprite](/reference/game/create-sprite) property.
|
||||
|
||||
```sig
|
||||
game.createSprite(0,0).set(LedSpriteProperty.X, 0);
|
||||
@ -9,22 +9,39 @@ 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)
|
||||
>* ``x`` - the horizontal location to set the sprite at on the LED screen (`0`-`4`)
|
||||
>* ``y`` - the vertical location to set the sprite at on the LED screen (`0`-`4`)
|
||||
>* ``direction`` - the direction in degrees for the sprite to go when the next [move](/reference/game/move) happens. The degree range is from `-180` to `180`.
|
||||
>* ``brightness`` - how bright the LED sprite is. Completely dark is `0` and very bright is `255`.
|
||||
>* ``blink`` - how fast the sprite is will blink on and off. The blink rate is in milliseconds.
|
||||
|
||||
* **value**: the a [number](/types/number) value to set for the property.
|
||||
|
||||
## 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.
|
||||
Make an LED sprite move to random locations on the screen. Use button **A** to freeze and unfreeze the sprite while it's moving. When the sprite is frozen, it will blink and dim to half brightness.
|
||||
|
||||
```blocks
|
||||
let ball = game.createSprite(0, 2);
|
||||
basic.pause(2000);
|
||||
ball.set(LedSpriteProperty.X, 4);
|
||||
input.onButtonEvent(Button.A, input.buttonEventClick(), function () {
|
||||
if (freeze) {
|
||||
sprite.set(LedSpriteProperty.Brightness, 255)
|
||||
sprite.set(LedSpriteProperty.Blink, 0)
|
||||
} else {
|
||||
sprite.set(LedSpriteProperty.Brightness, 128)
|
||||
sprite.set(LedSpriteProperty.Blink, 200)
|
||||
}
|
||||
freeze = !(freeze)
|
||||
})
|
||||
let freeze = false
|
||||
let sprite: game.LedSprite = null
|
||||
sprite = game.createSprite(0, 0)
|
||||
basic.forever(function () {
|
||||
if (!(freeze)) {
|
||||
sprite.set(LedSpriteProperty.X, randint(0, 4))
|
||||
sprite.set(LedSpriteProperty.Y, randint(0, 4))
|
||||
}
|
||||
basic.pause(500)
|
||||
})
|
||||
```
|
||||
|
||||
## See also
|
||||
|
@ -17,7 +17,7 @@ Press button ``A`` as much as possible.
|
||||
At the end of 10 seconds, the program will show your score.
|
||||
|
||||
```blocks
|
||||
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
|
||||
input.onButtonEvent(Button.A, input.buttonEventClick(), () => {
|
||||
game.addScore(1)
|
||||
})
|
||||
game.startCountdown(10000)
|
||||
|
Reference in New Issue
Block a user