pxt-common-packages 11.1.4 → 11.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/built/common-sim.d.ts +98 -0
- package/built/common-sim.js +343 -0
- package/libs/azureiot/built/debug/binary.js +461 -461
- package/libs/browser-events/browserEvents.cpp +29 -0
- package/libs/browser-events/browserEvents.ts +167 -0
- package/libs/browser-events/keyboard.ts +481 -0
- package/libs/browser-events/pxt.json +14 -0
- package/libs/browser-events/shims.d.ts +13 -0
- package/libs/browser-events/sim/browserEvent.ts +21 -0
- package/libs/browser-events/sim/keyboard.ts +256 -0
- package/libs/browser-events/sim/mouseState.ts +81 -0
- package/libs/color/built/debug/binary.js +8 -8
- package/libs/color-sensor/built/debug/binary.js +8 -8
- package/libs/controller/built/debug/binary.js +7608 -7582
- package/libs/controller---none/built/debug/binary.js +7587 -7561
- package/libs/datalogger/built/debug/binary.js +63 -63
- package/libs/edge-connector/built/debug/binary.js +8 -8
- package/libs/esp32/built/debug/binary.js +462 -462
- package/libs/game/built/debug/binary.js +7500 -7474
- package/libs/game/camera.ts +2 -2
- package/libs/game/controller.ts +2 -2
- package/libs/game/docs/reference/animation/animation-frames.md +77 -0
- package/libs/game/docs/reference/images/image/equals.md +68 -0
- package/libs/game/docs/reference/images/image.md +65 -0
- package/libs/game/docs/reference/images/sprite-image.md +43 -0
- package/libs/game/docs/reference/info/change-countdown-by.md +26 -0
- package/libs/game/docs/reference/info/change-score-by.md +1 -1
- package/libs/game/docs/reference/info/countdown.md +52 -0
- package/libs/game/docs/reference/sprites/all-of-kind.md +71 -0
- package/libs/game/docs/reference/sprites/on-overlap.md +1 -1
- package/libs/game/game.ts +1 -1
- package/libs/game/info.ts +2 -2
- package/libs/game/spriteevents.ts +1 -1
- package/libs/game/sprites.ts +1 -1
- package/libs/lcd/built/debug/binary.js +8 -8
- package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
- package/libs/lora/built/debug/binary.js +8 -8
- package/libs/matrix-keypad/built/debug/binary.js +8 -8
- package/libs/mqtt/built/debug/binary.js +176 -176
- package/libs/net/built/debug/binary.js +176 -176
- package/libs/net-game/built/debug/binary.js +9348 -9322
- package/libs/palette/built/debug/binary.js +7499 -7473
- package/libs/pixel/built/debug/binary.js +8 -8
- package/libs/power/built/debug/binary.js +8 -8
- package/libs/proximity/built/debug/binary.js +8 -8
- package/libs/radio/built/debug/binary.js +8 -8
- package/libs/radio-broadcast/built/debug/binary.js +8 -8
- package/libs/rotary-encoder/built/debug/binary.js +8 -8
- package/libs/screen/built/debug/binary.js +50 -50
- package/libs/screen/fieldeditors.ts +2 -0
- package/libs/screen/image.d.ts +1 -0
- package/libs/servo/built/debug/binary.js +8 -8
- package/libs/sprite-scaling/built/debug/binary.js +7499 -7473
- package/libs/storyboard/built/debug/binary.js +7499 -7473
- package/package.json +1 -1
package/libs/game/camera.ts
CHANGED
|
@@ -86,8 +86,8 @@ namespace scene {
|
|
|
86
86
|
if (this.sprite) {
|
|
87
87
|
this._lastUpdatedSpriteX = this.sprite.x;
|
|
88
88
|
this._lastUpdatedSpriteY = this.sprite.y;
|
|
89
|
-
this.offsetX = this.sprite.
|
|
90
|
-
this.offsetY = this.sprite.
|
|
89
|
+
this.offsetX = this.sprite.left + (this.sprite.width >> 1) - (screen.width >> 1);
|
|
90
|
+
this.offsetY = this.sprite.top + (this.sprite.width >> 1) - (screen.height >> 1);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
this.drawOffsetX = this.offsetX;
|
package/libs/game/controller.ts
CHANGED
|
@@ -303,7 +303,7 @@ namespace controller {
|
|
|
303
303
|
* Get the vertical movement, given the step and state of buttons
|
|
304
304
|
* @param step the distance, eg: 100
|
|
305
305
|
*/
|
|
306
|
-
//% weight=49 help=
|
|
306
|
+
//% weight=49 help=controller/dy
|
|
307
307
|
//% blockId=ctrldy block="%controller dy (up-down buttons)||scaled by %step"
|
|
308
308
|
//% step.defl=100
|
|
309
309
|
//% group="Multiplayer"
|
|
@@ -458,7 +458,7 @@ namespace controller {
|
|
|
458
458
|
* Get the vertical movement, given the step and state of buttons
|
|
459
459
|
* @param step the distance, eg: 100
|
|
460
460
|
*/
|
|
461
|
-
//% weight=49 help=
|
|
461
|
+
//% weight=49 help=controller/dy
|
|
462
462
|
//% blockId=keydy block="dy (up-down buttons)||scaled by %step"
|
|
463
463
|
//% step.defl=100
|
|
464
464
|
//% group="Single Player"
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# animation Frames
|
|
2
|
+
|
|
3
|
+
A sequence of image frames for an animation.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
animation._animationFrames(null)
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
The frames of an animation are set as an array of images. The block for containing the frames provides access to the image editor to create new frames and edit the ones already in the animation.
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
* **frames**: an array of images that create the animation.
|
|
14
|
+
|
|
15
|
+
## Example #example
|
|
16
|
+
|
|
17
|
+
Create and run an animation of a person walking. Click on the animation frames block to edit the animation. Loop the animation and then
|
|
18
|
+
stop it by pressing button **A**.
|
|
19
|
+
|
|
20
|
+
```blocks
|
|
21
|
+
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
|
|
22
|
+
animation.stopAnimation(animation.AnimationTypes.All, mySprite)
|
|
23
|
+
})
|
|
24
|
+
let mySprite: Sprite = null
|
|
25
|
+
scene.setBackgroundColor(1)
|
|
26
|
+
mySprite = sprites.create(img`
|
|
27
|
+
. . . . . . . . . . . . . . . .
|
|
28
|
+
. . . . . . . . . . . . . . . .
|
|
29
|
+
. . . . . . . . . . . . . . . .
|
|
30
|
+
. . . . . . . . . . . . . . . .
|
|
31
|
+
. . . . . . . . . . . . . . . .
|
|
32
|
+
. . . . . . . . . . . . . . . .
|
|
33
|
+
. . . . . . . . . . . . . . . .
|
|
34
|
+
. . . . . . . . . . . . . . . .
|
|
35
|
+
. . . . . . . . . . . . . . . .
|
|
36
|
+
. . . . . . . . . . . . . . . .
|
|
37
|
+
. . . . . . . . . . . . . . . .
|
|
38
|
+
. . . . . . . . . . . . . . . .
|
|
39
|
+
. . . . . . . . . . . . . . . .
|
|
40
|
+
. . . . . . . . . . . . . . . .
|
|
41
|
+
. . . . . . . . . . . . . . . .
|
|
42
|
+
. . . . . . . . . . . . . . . .
|
|
43
|
+
`, SpriteKind.Player)
|
|
44
|
+
let walker = animation._animationFrames([img`
|
|
45
|
+
. . . . . . . . . . . . . . . .
|
|
46
|
+
. . . . . . . . . . . . . . . .
|
|
47
|
+
. . . . . . . . . . . . . . . .
|
|
48
|
+
. . . . . . . . . . . . . . . .
|
|
49
|
+
. . . . . . . . . . . . . . . .
|
|
50
|
+
. . . . . . . . . . . . . . . .
|
|
51
|
+
. . . . . . . . . . . . . . . .
|
|
52
|
+
. . . . . . . . . . . . . . . .
|
|
53
|
+
. . . . . . . . . . . . . . . .
|
|
54
|
+
. . . . . . . . . . . . . . . .
|
|
55
|
+
. . . . . . . . . . . . . . . .
|
|
56
|
+
. . . . . . . . . . . . . . . .
|
|
57
|
+
. . . . . . . . . . . . . . . .
|
|
58
|
+
. . . . . . . . . . . . . . . .
|
|
59
|
+
. . . . . . . . . . . . . . . .
|
|
60
|
+
. . . . . . . . . . . . . . . .
|
|
61
|
+
`])
|
|
62
|
+
animation.runImageAnimation(
|
|
63
|
+
mySprite,
|
|
64
|
+
walker,
|
|
65
|
+
500,
|
|
66
|
+
true
|
|
67
|
+
)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## See Also #seealso
|
|
71
|
+
|
|
72
|
+
[run image animation](/reference/animation/run-image-animation),
|
|
73
|
+
[run movement animation](/reference/animation/run-movement-animation)
|
|
74
|
+
|
|
75
|
+
```package
|
|
76
|
+
animation
|
|
77
|
+
```
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# equals
|
|
2
|
+
|
|
3
|
+
Compare this image to another image to see if they are the same.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
image.create(0, 0).equals(null)
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Each pixel in the image is compared with another image. If all the pixels in both images are identical, then the images are considered "equal".
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
* **other**: the other image to compare this one to.
|
|
14
|
+
|
|
15
|
+
## Returns
|
|
16
|
+
|
|
17
|
+
* a [boolean](/types/boolean) value that is `true` if all of the pixels in the two images are identical, or a value of `false` otherwise.
|
|
18
|
+
|
|
19
|
+
## Example #example
|
|
20
|
+
|
|
21
|
+
Create sprite with using a `burger` image. Create just an image of the same burger using a variable. Compare that image with the image in the sprite to see if they are equal.
|
|
22
|
+
|
|
23
|
+
```blocks
|
|
24
|
+
let mySprite = sprites.create(img`
|
|
25
|
+
. . . . c c c b b b b b . . . .
|
|
26
|
+
. . c c b 4 4 4 4 4 4 b b b . .
|
|
27
|
+
. c c 4 4 4 4 4 5 4 4 4 4 b c .
|
|
28
|
+
. e 4 4 4 4 4 4 4 4 4 5 4 4 e .
|
|
29
|
+
e b 4 5 4 4 5 4 4 4 4 4 4 4 b c
|
|
30
|
+
e b 4 4 4 4 4 4 4 4 4 4 5 4 4 e
|
|
31
|
+
e b b 4 4 4 4 4 4 4 4 4 4 4 b e
|
|
32
|
+
. e b 4 4 4 4 4 5 4 4 4 4 b e .
|
|
33
|
+
8 7 e e b 4 4 4 4 4 4 b e e 6 8
|
|
34
|
+
8 7 2 e e e e e e e e e e 2 7 8
|
|
35
|
+
e 6 6 2 2 2 2 2 2 2 2 2 2 6 c e
|
|
36
|
+
e c 6 7 6 6 7 7 7 6 6 7 6 c c e
|
|
37
|
+
e b e 8 8 c c 8 8 c c c 8 e b e
|
|
38
|
+
e e b e c c e e e e e c e b e e
|
|
39
|
+
. e e b b 4 4 4 4 4 4 4 4 e e .
|
|
40
|
+
. . . c c c c c e e e e e . . .
|
|
41
|
+
`, SpriteKind.Food)
|
|
42
|
+
let burger = img`
|
|
43
|
+
. . . . c c c b b b b b . . . .
|
|
44
|
+
. . c c b 4 4 4 4 4 4 b b b . .
|
|
45
|
+
. c c 4 4 4 4 4 5 4 4 4 4 b c .
|
|
46
|
+
. e 4 4 4 4 4 4 4 4 4 5 4 4 e .
|
|
47
|
+
e b 4 5 4 4 5 4 4 4 4 4 4 4 b c
|
|
48
|
+
e b 4 4 4 4 4 4 4 4 4 4 5 4 4 e
|
|
49
|
+
e b b 4 4 4 4 4 4 4 4 4 4 4 b e
|
|
50
|
+
. e b 4 4 4 4 4 5 4 4 4 4 b e .
|
|
51
|
+
8 7 e e b 4 4 4 4 4 4 b e e 6 8
|
|
52
|
+
8 7 2 e e e e e e e e e e 2 7 8
|
|
53
|
+
e 6 6 2 2 2 2 2 2 2 2 2 2 6 c e
|
|
54
|
+
e c 6 7 6 6 7 7 7 6 6 7 6 c c e
|
|
55
|
+
e b e 8 8 c c 8 8 c c c 8 e b e
|
|
56
|
+
e e b e c c e e e e e c e b e e
|
|
57
|
+
. e e b b 4 4 4 4 4 4 4 4 e e .
|
|
58
|
+
. . . c c c c c e e e e e . . .
|
|
59
|
+
`
|
|
60
|
+
if (burger.equals(mySprite.image)) {
|
|
61
|
+
mySprite.sayText("I'm a burger!", 2000, false)
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## See Also #seealso
|
|
66
|
+
|
|
67
|
+
[clone](/reference/images/image/clone),
|
|
68
|
+
[get pixel](/reference/images/image/get-pixel)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# image
|
|
2
|
+
|
|
3
|
+
The container and editor block for an image.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
images._image(null)
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Clicking on the image window in the block will open the image editor and a you can create a new image or edit the current one. The image is used to assign to a sprite or as a frame in an animation.
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
* **image**: The [image](/types/image) to contain in the block.
|
|
14
|
+
|
|
15
|
+
## Example #example
|
|
16
|
+
|
|
17
|
+
Create a new `food` sprite with an image of a donut. When the game score reaches `100`, upgrade food sprite to the `cake` image.
|
|
18
|
+
|
|
19
|
+
```blocks
|
|
20
|
+
info.onScore(100, function () {
|
|
21
|
+
mySprite.setImage(cake)
|
|
22
|
+
})
|
|
23
|
+
let cake: Image = null
|
|
24
|
+
let mySprite: Sprite = null
|
|
25
|
+
mySprite = sprites.create(img`
|
|
26
|
+
. . . . . . b b b b a a . . . .
|
|
27
|
+
. . . . b b d d d 3 3 3 a a . .
|
|
28
|
+
. . . b d d d 3 3 3 3 3 3 a a .
|
|
29
|
+
. . b d d 3 3 3 3 3 3 3 3 3 a .
|
|
30
|
+
. b 3 d 3 3 3 3 3 b 3 3 3 3 a b
|
|
31
|
+
. b 3 3 3 3 3 a a 3 3 3 3 3 a b
|
|
32
|
+
b 3 3 3 3 3 a a 3 3 3 3 d a 4 b
|
|
33
|
+
b 3 3 3 3 b a 3 3 3 3 3 d a 4 b
|
|
34
|
+
b 3 3 3 3 3 3 3 3 3 3 d a 4 4 e
|
|
35
|
+
a 3 3 3 3 3 3 3 3 3 d a 4 4 4 e
|
|
36
|
+
a 3 3 3 3 3 3 3 d d a 4 4 4 e .
|
|
37
|
+
a a 3 3 3 d d d a a 4 4 4 e e .
|
|
38
|
+
. e a a a a a a 4 4 4 4 e e . .
|
|
39
|
+
. . e e b b 4 4 4 4 b e e . . .
|
|
40
|
+
. . . e e e e e e e e . . . . .
|
|
41
|
+
. . . . . . . . . . . . . . . .
|
|
42
|
+
`, SpriteKind.Food)
|
|
43
|
+
cake = img`
|
|
44
|
+
. . . . . . . . . . b b b . . .
|
|
45
|
+
. . . . . . . . b e e 3 3 b . .
|
|
46
|
+
. . . . . . b b e 3 2 e 3 a . .
|
|
47
|
+
. . . . b b 3 3 e 2 2 e 3 3 a .
|
|
48
|
+
. . b b 3 3 3 3 3 e e 3 3 3 a .
|
|
49
|
+
b b 3 3 3 3 3 3 3 3 3 3 3 3 3 a
|
|
50
|
+
b 3 3 3 d d d d 3 3 3 3 3 d d a
|
|
51
|
+
b b b b b b b 3 d d d d d d 3 a
|
|
52
|
+
b d 5 5 5 5 d b b b a a a a a a
|
|
53
|
+
b 3 d d 5 5 5 5 5 5 5 d d d d a
|
|
54
|
+
b 3 3 3 3 3 3 d 5 5 5 d d d d a
|
|
55
|
+
b 3 d 5 5 5 3 3 3 3 3 3 b b b a
|
|
56
|
+
b b b 3 d 5 5 5 5 5 5 5 d d b a
|
|
57
|
+
. . . b b b 3 d 5 5 5 5 d d 3 a
|
|
58
|
+
. . . . . . b b b b 3 d d d b a
|
|
59
|
+
. . . . . . . . . . b b b a a .
|
|
60
|
+
`
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## See also
|
|
64
|
+
|
|
65
|
+
[create](/reference/images/create)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# sprite Image
|
|
2
|
+
|
|
3
|
+
The container and editor block for a sprite image.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
images._spriteImage(null)
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Clicking on the image window in the block will open the image editor and a you can create a new image or edit the current one. The image is used when a sprite is created or as a different image to assign to a sprite.
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
* **image**: The [image](/types/image) to use for a sprite.
|
|
14
|
+
|
|
15
|
+
## Example #example
|
|
16
|
+
|
|
17
|
+
Create a new sprite with an image of a donut.
|
|
18
|
+
|
|
19
|
+
```blocks
|
|
20
|
+
let mySprite = sprites.create(img`
|
|
21
|
+
. . . . . . b b b b a a . . . .
|
|
22
|
+
. . . . b b d d d 3 3 3 a a . .
|
|
23
|
+
. . . b d d d 3 3 3 3 3 3 a a .
|
|
24
|
+
. . b d d 3 3 3 3 3 3 3 3 3 a .
|
|
25
|
+
. b 3 d 3 3 3 3 3 b 3 3 3 3 a b
|
|
26
|
+
. b 3 3 3 3 3 a a 3 3 3 3 3 a b
|
|
27
|
+
b 3 3 3 3 3 a a 3 3 3 3 d a 4 b
|
|
28
|
+
b 3 3 3 3 b a 3 3 3 3 3 d a 4 b
|
|
29
|
+
b 3 3 3 3 3 3 3 3 3 3 d a 4 4 e
|
|
30
|
+
a 3 3 3 3 3 3 3 3 3 d a 4 4 4 e
|
|
31
|
+
a 3 3 3 3 3 3 3 d d a 4 4 4 e .
|
|
32
|
+
a a 3 3 3 d d d a a 4 4 4 e e .
|
|
33
|
+
. e a a a a a a 4 4 4 4 e e . .
|
|
34
|
+
. . e e b b 4 4 4 4 b e e . . .
|
|
35
|
+
. . . e e e e e e e e . . . . .
|
|
36
|
+
. . . . . . . . . . . . . . . .
|
|
37
|
+
`, SpriteKind.Food)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## See also
|
|
41
|
+
|
|
42
|
+
[create](/reference/sprites/create),
|
|
43
|
+
[set image](/reference/sprites/sprite/set-image)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# change Countdown By
|
|
2
|
+
|
|
3
|
+
Change the current game countdown time up or down by this amount.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
info.changeCountdownBy(0)
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
The current game countdown time amount is increased by adding the change value when it is greater than zero (positive). If the change number is less than zero (negative), the game countdown is reduced by the value of the change number.
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
* **value**: a [number](/types/number) seconds to change the game countdown by.
|
|
14
|
+
|
|
15
|
+
## Example #example
|
|
16
|
+
|
|
17
|
+
Reduce game countdown time by `3` seconds.
|
|
18
|
+
|
|
19
|
+
```blocks
|
|
20
|
+
info.changeCountdown(-3)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## See also #seealso
|
|
24
|
+
|
|
25
|
+
[countdown](/reference/info/score),
|
|
26
|
+
[on countdown end](/reference/info/on-countdown-end)
|
|
@@ -10,7 +10,7 @@ The total score amount is increased by adding the change value when it is greate
|
|
|
10
10
|
|
|
11
11
|
## Parameters
|
|
12
12
|
|
|
13
|
-
* **value**: a [number](/types/number) to
|
|
13
|
+
* **value**: a [number](/types/number) whice is the amount to change the current score by.
|
|
14
14
|
|
|
15
15
|
## Example #example
|
|
16
16
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# countdown
|
|
2
|
+
|
|
3
|
+
Get the current game countdown time.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
info.changeCountdownBy(0)
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
The current game countdown time amount is increased by adding the change value when it is greater than zero (positive). If the change number is less than zero (negative), the game countdown is reduced by the value of the change number.
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
* **value**: a [number](/types/number) to set the game countdown by.
|
|
14
|
+
|
|
15
|
+
## Returns
|
|
16
|
+
|
|
17
|
+
* a [number](/types/number) that is the amount of time remaining for the game countdown in seconds.
|
|
18
|
+
|
|
19
|
+
## Example #example
|
|
20
|
+
|
|
21
|
+
Give a sprite warning message when the game countdown time is less than `5` seconds.
|
|
22
|
+
|
|
23
|
+
```blocks
|
|
24
|
+
info.startCountdown(30)
|
|
25
|
+
let mySprite = sprites.create(img`
|
|
26
|
+
. . . . . . . . . . . . . . . .
|
|
27
|
+
. . 4 4 4 . . . . 4 4 4 . . . .
|
|
28
|
+
. 4 5 5 5 e . . e 5 5 5 4 . . .
|
|
29
|
+
4 5 5 5 5 5 e e 5 5 5 5 5 4 . .
|
|
30
|
+
4 5 5 4 4 5 5 5 5 4 4 5 5 4 . .
|
|
31
|
+
e 5 4 4 5 5 5 5 5 5 4 4 5 e . .
|
|
32
|
+
. e e 5 5 5 5 5 5 5 5 e e . . .
|
|
33
|
+
. . e 5 f 5 5 5 5 f 5 e . . . .
|
|
34
|
+
. . f 5 5 5 4 4 5 5 5 f . f f .
|
|
35
|
+
. . . 4 5 5 f f 5 5 6 f f 5 f .
|
|
36
|
+
. . . f 6 6 6 6 6 6 4 f 5 5 f .
|
|
37
|
+
. . . f 5 5 5 5 5 5 5 4 5 f . .
|
|
38
|
+
. . . . f 5 4 5 f 5 f f f . . .
|
|
39
|
+
. . . . . f f f f f f f . . . .
|
|
40
|
+
`, SpriteKind.Player)
|
|
41
|
+
game.onUpdateInterval(500, function () {
|
|
42
|
+
if (info.countdown() < 5) {
|
|
43
|
+
mySprite.sayText("Short on time!")
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## See also #seealso
|
|
49
|
+
|
|
50
|
+
[start countdown](/reference/info/start-countdown),
|
|
51
|
+
[change countdown by](/reference/info/change-countdown-by),
|
|
52
|
+
[on countdown end](/reference/info/on-countdown-end)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# all Of Kind
|
|
2
|
+
|
|
3
|
+
Get all the sprites of a certain kind.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
sprites.allOfKind(SpriteKind.Player)
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
You can get an array of the current sprites of a particular kind. For example, you want to find out where of all of the `Enemy` sprites in your game are, you could get an array of them and check their location.
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
* **kind**: the kind of the sprites you want an array of, such as `Player` or `Enemy`.
|
|
14
|
+
|
|
15
|
+
## Example #example
|
|
16
|
+
|
|
17
|
+
Set a player in the center of the screen. Make a bunch of blobs appear at random positions. If there are any blobs too close to the player, have them destroyed when button `A` is pressed.
|
|
18
|
+
|
|
19
|
+
```blocks
|
|
20
|
+
namespace SpriteKind {
|
|
21
|
+
export const Blob = SpriteKind.create()
|
|
22
|
+
}
|
|
23
|
+
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
|
|
24
|
+
for (let icky of sprites.allOfKind(SpriteKind.Blob)) {
|
|
25
|
+
x2 = (icky.x - mySprite.x) ** 2
|
|
26
|
+
y2 = (icky.y - mySprite.y) ** 2
|
|
27
|
+
if (Math.sqrt(x2 + y2) < mySprite.width * 2) {
|
|
28
|
+
sprites.destroy(icky, effects.disintegrate, 500)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
let y2 = 0
|
|
33
|
+
let x2 = 0
|
|
34
|
+
let blob: Sprite = null
|
|
35
|
+
let mySprite: Sprite = null
|
|
36
|
+
mySprite = sprites.create(img`
|
|
37
|
+
. . . . . f f f f . . . . .
|
|
38
|
+
. . . f f 5 5 5 5 f f . . .
|
|
39
|
+
. . f 5 5 5 5 5 5 5 5 f . .
|
|
40
|
+
. f 5 5 5 5 5 5 5 5 5 5 f .
|
|
41
|
+
. f 5 5 5 d b b d 5 5 5 f .
|
|
42
|
+
f 5 5 5 b 4 4 4 4 b 5 5 5 f
|
|
43
|
+
f 5 5 c c 4 4 4 4 c c 5 5 f
|
|
44
|
+
f b b f b f 4 4 f b f b b f
|
|
45
|
+
f b b 4 1 f d d f 1 4 b b f
|
|
46
|
+
. f b f d d d d d d f b f .
|
|
47
|
+
. f e f e 4 4 4 4 e f e f .
|
|
48
|
+
. e 4 f 6 9 9 9 9 6 f 4 e .
|
|
49
|
+
. 4 d c 9 9 9 9 9 9 c d 4 .
|
|
50
|
+
. 4 f b 3 b 3 b 3 b b f 4 .
|
|
51
|
+
. . f f 3 b 3 b 3 3 f f . .
|
|
52
|
+
. . . . f f b b f f . . . .
|
|
53
|
+
`, SpriteKind.Player)
|
|
54
|
+
for (let index = 0; index < 40; index++) {
|
|
55
|
+
blob = sprites.create(img`
|
|
56
|
+
. 2 2 2 . 2 2 .
|
|
57
|
+
2 2 5 2 2 2 2 2
|
|
58
|
+
2 f 2 2 5 2 2 .
|
|
59
|
+
2 2 2 2 2 2 2 2
|
|
60
|
+
2 2 2 2 2 2 2 2
|
|
61
|
+
2 2 f 2 f 2 2 2
|
|
62
|
+
. 2 2 2 2 2 2 .
|
|
63
|
+
. 2 . 2 2 5 2 .
|
|
64
|
+
`, SpriteKind.Blob)
|
|
65
|
+
blob.setPosition(randint(0, scene.screenWidth()), randint(0, scene.screenHeight()))
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## See also #seealso
|
|
70
|
+
|
|
71
|
+
[destroy all sprites of kind](/reference/sprites/sprite/destroy-all-sprites-of-kind)
|
|
@@ -76,7 +76,7 @@ sprites.onOverlap(SpriteKind.Mortal, SpriteKind.Ball, function (sprite, otherSpr
|
|
|
76
76
|
sprite.x += -1
|
|
77
77
|
})
|
|
78
78
|
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
|
|
79
|
-
ghost.
|
|
79
|
+
ghost.setKind(SpriteKind.Mortal)
|
|
80
80
|
})
|
|
81
81
|
sprites.onDestroyed(SpriteKind.Mortal, function (sprite) {
|
|
82
82
|
game.over()
|
package/libs/game/game.ts
CHANGED
|
@@ -283,7 +283,7 @@ namespace game {
|
|
|
283
283
|
//% group="Game Over"
|
|
284
284
|
//% weight=80
|
|
285
285
|
//% blockGap=8
|
|
286
|
-
//% help=game/set-game-over-
|
|
286
|
+
//% help=game/set-game-over-playable
|
|
287
287
|
export function setGameOverPlayable(win: boolean, sound: music.Playable, looping: boolean) {
|
|
288
288
|
init();
|
|
289
289
|
const goc = game.gameOverConfig();
|
package/libs/game/info.ts
CHANGED
|
@@ -422,7 +422,7 @@ namespace info {
|
|
|
422
422
|
*/
|
|
423
423
|
//% block="countdown"
|
|
424
424
|
//% blockId=gamegetcountdown
|
|
425
|
-
//% weight=79
|
|
425
|
+
//% weight=79 help=info/countdown
|
|
426
426
|
//% group="Countdown"
|
|
427
427
|
export function countdown(): number {
|
|
428
428
|
initHUD();
|
|
@@ -448,7 +448,7 @@ namespace info {
|
|
|
448
448
|
*/
|
|
449
449
|
//% block="change countdown by $seconds (s)"
|
|
450
450
|
//% blockId=gamechangecountdown
|
|
451
|
-
//% weight=77
|
|
451
|
+
//% weight=77 help=info/change-countdown-by
|
|
452
452
|
//% group="Countdown"
|
|
453
453
|
export function changeCountdownBy(seconds: number) {
|
|
454
454
|
startCountdown((countdown() + seconds));
|
|
@@ -46,7 +46,7 @@ namespace sprites {
|
|
|
46
46
|
//% group="Overlaps"
|
|
47
47
|
//% weight=100 draggableParameters="reporter"
|
|
48
48
|
//% blockId=spritesoverlap block="on $sprite of kind $kind=spritekind overlaps $otherSprite of kind $otherKind=spritekind"
|
|
49
|
-
//% help=
|
|
49
|
+
//% help=sprites/on-overlap
|
|
50
50
|
//% blockGap=8
|
|
51
51
|
export function onOverlap(kind: number, otherKind: number, handler: (sprite: Sprite, otherSprite: Sprite) => void) {
|
|
52
52
|
if (kind == undefined || otherKind == undefined || !handler) return;
|
package/libs/game/sprites.ts
CHANGED
|
@@ -78,7 +78,7 @@ namespace sprites {
|
|
|
78
78
|
* @param kind the target kind
|
|
79
79
|
*/
|
|
80
80
|
//% blockId=allOfKind block="array of sprites of kind %kind=spritekind"
|
|
81
|
-
//% weight=87
|
|
81
|
+
//% weight=87 help=sprites/all-of-kind
|
|
82
82
|
export function allOfKind(kind: number): Sprite[] {
|
|
83
83
|
const spritesByKind = game.currentScene().spritesByKind;
|
|
84
84
|
if (!(kind >= 0) || !spritesByKind[kind]) return [];
|
|
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
|
|
|
56
56
|
const pxsim_numops = pxsim.numops;
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function _main___P48910(s) {
|
|
60
60
|
let r0 = s.r0, step = s.pc;
|
|
61
61
|
s.pc = -1;
|
|
62
62
|
|
|
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
|
|
|
66
66
|
switch (step) {
|
|
67
67
|
case 0:
|
|
68
68
|
|
|
69
|
-
globals.
|
|
70
|
-
globals.
|
|
69
|
+
globals._intervals___49153 = (undefined);
|
|
70
|
+
globals._pollEventQueue___49166 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P48910.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P48910.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P48910_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P48910, depth: s.depth + 1,
|
|
82
82
|
pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
|
|
83
83
|
} }
|
|
84
84
|
|
|
@@ -88,5 +88,5 @@ function _main___P48898_mk(s) {
|
|
|
88
88
|
|
|
89
89
|
const breakpoints = setupDebugger(1, [])
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return _main___P48910
|
|
92
92
|
})
|
|
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
|
|
|
56
56
|
const pxsim_numops = pxsim.numops;
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function _main___P99068(s) {
|
|
60
60
|
let r0 = s.r0, step = s.pc;
|
|
61
61
|
s.pc = -1;
|
|
62
62
|
|
|
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
|
|
|
66
66
|
switch (step) {
|
|
67
67
|
case 0:
|
|
68
68
|
|
|
69
|
-
globals.
|
|
70
|
-
globals.
|
|
69
|
+
globals._intervals___99311 = (undefined);
|
|
70
|
+
globals._pollEventQueue___99324 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P99068.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P99068.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P99068_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P99068, depth: s.depth + 1,
|
|
82
82
|
pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
|
|
83
83
|
} }
|
|
84
84
|
|
|
@@ -88,5 +88,5 @@ function _main___P99032_mk(s) {
|
|
|
88
88
|
|
|
89
89
|
const breakpoints = setupDebugger(1, [])
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return _main___P99068
|
|
92
92
|
})
|
|
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
|
|
|
56
56
|
const pxsim_numops = pxsim.numops;
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function _main___P60218(s) {
|
|
60
60
|
let r0 = s.r0, step = s.pc;
|
|
61
61
|
s.pc = -1;
|
|
62
62
|
|
|
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
|
|
|
66
66
|
switch (step) {
|
|
67
67
|
case 0:
|
|
68
68
|
|
|
69
|
-
globals.
|
|
70
|
-
globals.
|
|
69
|
+
globals._intervals___60461 = (undefined);
|
|
70
|
+
globals._pollEventQueue___60474 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P60218.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P60218.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P60218_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P60218, depth: s.depth + 1,
|
|
82
82
|
pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
|
|
83
83
|
} }
|
|
84
84
|
|
|
@@ -88,5 +88,5 @@ function _main___P60206_mk(s) {
|
|
|
88
88
|
|
|
89
89
|
const breakpoints = setupDebugger(1, [])
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return _main___P60218
|
|
92
92
|
})
|
|
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
|
|
|
56
56
|
const pxsim_numops = pxsim.numops;
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function _main___P192896(s) {
|
|
60
60
|
let r0 = s.r0, step = s.pc;
|
|
61
61
|
s.pc = -1;
|
|
62
62
|
|
|
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
|
|
|
66
66
|
switch (step) {
|
|
67
67
|
case 0:
|
|
68
68
|
|
|
69
|
-
globals.
|
|
70
|
-
globals.
|
|
69
|
+
globals._intervals___193139 = (undefined);
|
|
70
|
+
globals._pollEventQueue___193152 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P192896.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P192896.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P192896_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P192896, depth: s.depth + 1,
|
|
82
82
|
pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
|
|
83
83
|
} }
|
|
84
84
|
|
|
@@ -88,5 +88,5 @@ function _main___P192812_mk(s) {
|
|
|
88
88
|
|
|
89
89
|
const breakpoints = setupDebugger(1, [])
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return _main___P192896
|
|
92
92
|
})
|