pxt-common-packages 10.4.4 → 10.4.5
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 +14 -0
- package/built/common-sim.js +98 -0
- package/libs/azureiot/built/debug/binary.js +461 -461
- package/libs/color/built/debug/binary.js +8 -8
- package/libs/{game/docs/reference/scene → color-coded-tilemap/docs/reference/color-coded-tilemap}/get-tile.md +3 -3
- package/libs/color-coded-tilemap/docs/reference/color-coded-tilemap/get-tiles-by-type.md +65 -0
- package/libs/{game/docs/reference/scene → color-coded-tilemap/docs/reference/color-coded-tilemap}/on-hit-tile.md +4 -4
- package/libs/color-coded-tilemap/docs/reference/color-coded-tilemap/place-on-random-tile.md +61 -0
- package/libs/{game/docs/reference/scene → color-coded-tilemap/docs/reference/color-coded-tilemap}/place.md +2 -6
- package/libs/color-coded-tilemap/docs/reference/color-coded-tilemap/set-tile-at.md +61 -0
- package/libs/{game/docs/reference/scene → color-coded-tilemap/docs/reference/color-coded-tilemap}/set-tile-map.md +3 -3
- package/libs/{game/docs/reference/scene → color-coded-tilemap/docs/reference/color-coded-tilemap}/set-tile.md +1 -1
- package/libs/{game/docs/reference/scene → color-coded-tilemap/docs/reference/color-coded-tilemap}/tile-map.md +2 -2
- package/libs/{game/docs/types → color-coded-tilemap/docs/reference/color-coded-tilemap}/tile.md +9 -5
- package/libs/color-coded-tilemap/docs/reference/color-coded-tilemap.md +32 -0
- package/libs/color-coded-tilemap/tilemap.ts +7 -7
- package/libs/color-sensor/built/debug/binary.js +8 -8
- package/libs/controller/built/debug/binary.js +7117 -7117
- package/libs/controller---none/built/debug/binary.js +7097 -7097
- package/libs/datalogger/built/debug/binary.js +63 -63
- package/libs/edge-connector/built/debug/binary.js +8 -8
- package/libs/edge-connector/docs/reference/edge-connector.md +5 -0
- package/libs/esp32/built/debug/binary.js +462 -462
- package/libs/feather/docs/reference/feather.md +11 -0
- package/libs/game/built/debug/binary.js +7036 -7036
- 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/mixer/instrument.ts +28 -9
- package/libs/mixer/melody.cpp +43 -0
- package/libs/mixer/sequencer.ts +116 -0
- package/libs/mixer/sim/music.ts +102 -0
- 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 +8625 -8625
- package/libs/palette/built/debug/binary.js +7035 -7035
- 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/servo/built/debug/binary.js +8 -8
- package/libs/sprite-scaling/_locales/sprite-scaling-jsdoc-strings.json +18 -1
- package/libs/sprite-scaling/_locales/sprite-scaling-strings.json +1 -0
- package/libs/sprite-scaling/built/debug/binary.js +7035 -7035
- package/libs/sprite-scaling/docs/reference/sprite-scaling.md +23 -0
- package/libs/sprite-scaling/docs/reference/sprites/scaling/scale-by-pixels.md +1 -1
- package/libs/sprite-scaling/docs/reference/sprites/scaling/scale-to-pixels.md +1 -1
- package/libs/sprite-scaling/scaling.ts +24 -0
- package/libs/storyboard/built/debug/binary.js +7035 -7035
- package/package.json +2 -2
|
@@ -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___P138383(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___138626 = (undefined);
|
|
70
|
+
globals._pollEventQueue___138639 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P138383.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"colorbuffer.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P138383.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P138383_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P138383, 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___P138247_mk(s) {
|
|
|
88
88
|
|
|
89
89
|
const breakpoints = setupDebugger(1, [])
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return _main___P138383
|
|
92
92
|
})
|
|
@@ -13,7 +13,7 @@ scene.getTile(0, 0)
|
|
|
13
13
|
|
|
14
14
|
## Returns
|
|
15
15
|
|
|
16
|
-
* a [tile](/
|
|
16
|
+
* a [tile](/reference/color-coded-tilemap/tile) from a location in the tilemap.
|
|
17
17
|
|
|
18
18
|
## Example #example
|
|
19
19
|
|
|
@@ -56,8 +56,8 @@ scene.setTileAt(scene.getTile(5, 3), 2)
|
|
|
56
56
|
|
|
57
57
|
## See also #seealso
|
|
58
58
|
|
|
59
|
-
[set tile](/reference/
|
|
60
|
-
[set tile at](/reference/
|
|
59
|
+
[set tile](/reference/color-coded-tilemap/set-tile),
|
|
60
|
+
[set tile at](/reference/color-coded-tilemap/set-tile-at)
|
|
61
61
|
|
|
62
62
|
```package
|
|
63
63
|
color-coded-tilemap
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# get Tiles By Type
|
|
2
|
+
|
|
3
|
+
Get a list of tiles in the tilemap that have the same color index.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
scene.getTilesByType(0)
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
All the tiles in the tilemap with the chosen **index** are returned in an array of [tiles](/reference/color-coded-tilemap/tile). You can use this array to change or replace the tiles as one group.
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
* **index**: the color index to the tiles to make a list for.
|
|
14
|
+
|
|
15
|
+
## Returns
|
|
16
|
+
|
|
17
|
+
* an [array](/types/array) of [tiles](/reference/color-coded-tilemap/tile) from the tilemap that have the same color **index**.
|
|
18
|
+
|
|
19
|
+
## Example #example
|
|
20
|
+
|
|
21
|
+
Get a list of all the tiles in the center of the tilemap. Replace all of them with the tile type used for the border.
|
|
22
|
+
|
|
23
|
+
```blocks
|
|
24
|
+
scene.setTile(2, img`
|
|
25
|
+
a a a a a a a a a a a a a a a a
|
|
26
|
+
a a a a a a a a a a a a a a a a
|
|
27
|
+
a a a a a a a a a a a a a a a a
|
|
28
|
+
a a a a a a a a a a a a a a a a
|
|
29
|
+
a a a a a a a a a a a a a a a a
|
|
30
|
+
a a a a a a a a a a a a a a a a
|
|
31
|
+
a a a a a a a a a a a a a a a a
|
|
32
|
+
a a a a a a a a a a a a a a a a
|
|
33
|
+
a a a a a a a a a a a a a a a a
|
|
34
|
+
a a a a a a a a a a a a a a a a
|
|
35
|
+
a a a a a a a a a a a a a a a a
|
|
36
|
+
a a a a a a a a a a a a a a a a
|
|
37
|
+
a a a a a a a a a a a a a a a a
|
|
38
|
+
a a a a a a a a a a a a a a a a
|
|
39
|
+
a a a a a a a a a a a a a a a a
|
|
40
|
+
a a a a a a a a a a a a a a a a
|
|
41
|
+
`)
|
|
42
|
+
scene.setTileMap(img`
|
|
43
|
+
2 2 2 2 2 2 2 2 2 2
|
|
44
|
+
2 8 . . . 8 . . . 2
|
|
45
|
+
2 . 8 . 8 . 8 . 8 2
|
|
46
|
+
2 . . 8 . . . 8 . 2
|
|
47
|
+
2 . 8 . 8 . 8 . 8 2
|
|
48
|
+
2 8 . . . 8 . . . 2
|
|
49
|
+
2 2 2 2 2 2 2 2 2 2
|
|
50
|
+
. . . . . . . . . .
|
|
51
|
+
`)
|
|
52
|
+
for (let tile of scene.getTilesByType(8)) {
|
|
53
|
+
scene.setTileAt(tile, 2)
|
|
54
|
+
pause(500)
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## See also #seealso
|
|
59
|
+
|
|
60
|
+
[get tile](/reference/color-coded-tilemap/get-tile),
|
|
61
|
+
[set tile at](/reference/color-coded-tilemap/set-tile-at)
|
|
62
|
+
|
|
63
|
+
```package
|
|
64
|
+
color-coded-tilemap
|
|
65
|
+
```
|
|
@@ -26,9 +26,9 @@ A a sprite hitting a wall is dectected when the outside edges of their images ma
|
|
|
26
26
|
Build a brick wall of tiles in the scene. Use the **A** to send a ``Ghost`` sprite toward the wall and watch it stop. When button **B** is pressed, switch the value of the ``ghost`` flag and see if the ghost sprite hits the wall or goes through.
|
|
27
27
|
|
|
28
28
|
```blocks
|
|
29
|
-
|
|
30
|
-
Ghost
|
|
31
|
-
Ball
|
|
29
|
+
namespace SpriteKind {
|
|
30
|
+
export const Ghost = SpriteKind.create()
|
|
31
|
+
export const Ball = SpriteKind.create()
|
|
32
32
|
}
|
|
33
33
|
let ghost: Sprite = null
|
|
34
34
|
scene.setTile(2, img`
|
|
@@ -102,4 +102,4 @@ controller.B.onEvent(ControllerButtonEvent.Pressed, function () {
|
|
|
102
102
|
|
|
103
103
|
```package
|
|
104
104
|
color-coded-tilemap
|
|
105
|
-
```
|
|
105
|
+
```
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# place On Random Tile
|
|
2
|
+
|
|
3
|
+
Move a sprite's position to the center of a random tile in the scene.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
scene.placeOnRandomTile(null, 0)
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
You can make a sprite locate itself right on top of a random tile in the tile map. Use the color number of type tile to select for the sprite to locate on one of them.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## Parameters
|
|
13
|
+
|
|
14
|
+
* **sprite**: the sprite to move onto the tile.
|
|
15
|
+
* **color**: the color [number](/types/number) of a tile to randomly select.
|
|
16
|
+
|
|
17
|
+
## Example #example
|
|
18
|
+
|
|
19
|
+
Make a tilemap with several different tiles. Create a round shaped sprite. Ramdomly place the sprite on a tile with color number `8`.
|
|
20
|
+
|
|
21
|
+
```blocks
|
|
22
|
+
let mySprite: Sprite = null
|
|
23
|
+
scene.setTileMap(img`
|
|
24
|
+
. . . . . . . . 3 .
|
|
25
|
+
. 2 . . . . . . . .
|
|
26
|
+
. . . . . 8 . . . .
|
|
27
|
+
. . . . . . . b . .
|
|
28
|
+
. . 8 . 6 . . . . .
|
|
29
|
+
. . . . . . 4 . . .
|
|
30
|
+
. a . . . . . . . .
|
|
31
|
+
. . . . . . . . e .
|
|
32
|
+
`)
|
|
33
|
+
mySprite = sprites.create(img`
|
|
34
|
+
. . . . . . . . . . . . . . . .
|
|
35
|
+
. . . . . . . . . . . . . . . .
|
|
36
|
+
. . . . . 7 7 7 7 7 7 . . . . .
|
|
37
|
+
. . . 7 7 7 7 7 7 7 7 7 7 . . .
|
|
38
|
+
. . . 7 7 7 7 7 7 7 7 7 7 . . .
|
|
39
|
+
. . 7 7 7 7 7 7 7 7 7 7 7 7 . .
|
|
40
|
+
. . 7 7 7 7 7 7 7 7 7 7 7 7 . .
|
|
41
|
+
. . 7 7 7 7 7 7 7 7 7 7 7 7 . .
|
|
42
|
+
. . 7 7 7 7 7 7 7 7 7 7 7 7 . .
|
|
43
|
+
. . 7 7 7 7 7 7 7 7 7 7 7 7 . .
|
|
44
|
+
. . 7 7 7 7 7 7 7 7 7 7 7 7 . .
|
|
45
|
+
. . . 7 7 7 7 7 7 7 7 7 7 . . .
|
|
46
|
+
. . . 7 7 7 7 7 7 7 7 7 7 . . .
|
|
47
|
+
. . . . . 7 7 7 7 7 7 . . . . .
|
|
48
|
+
. . . . . . . . . . . . . . . .
|
|
49
|
+
. . . . . . . . . . . . . . . .
|
|
50
|
+
`, SpriteKind.Player)
|
|
51
|
+
pause(1000)
|
|
52
|
+
scene.placeOnRandomTile(mySprite, 8)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## See also #seealso
|
|
56
|
+
|
|
57
|
+
[get tile](/reference/color-coded-tilemap/get-tile)
|
|
58
|
+
|
|
59
|
+
```package
|
|
60
|
+
color-coded-tilemap
|
|
61
|
+
```
|
|
@@ -6,7 +6,7 @@ Move a sprite's position to the center of a tile in the scene.
|
|
|
6
6
|
scene.getTile(0, 0).place(null)
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
You
|
|
9
|
+
You can make a sprite locate itself right on top of a tile. If you have a [tile](/reference/color-coded-tilemap/tile) object from the tilemap, just use **place** to put a sprite on top of it.
|
|
10
10
|
|
|
11
11
|
## Parameters
|
|
12
12
|
|
|
@@ -17,10 +17,6 @@ You a can make a sprite to locate itself right on top of a tile. If you have a [
|
|
|
17
17
|
Make a tilemap with several different tiles. Create a round shaped sprite. Choose the tile at position (1, 1) in the tilemap and place the sprite over it.
|
|
18
18
|
|
|
19
19
|
```blocks
|
|
20
|
-
enum SpriteKind {
|
|
21
|
-
Player,
|
|
22
|
-
Enemy
|
|
23
|
-
}
|
|
24
20
|
let mySprite: Sprite = null
|
|
25
21
|
scene.setTileMap(img`
|
|
26
22
|
. . . . . . . . 3 .
|
|
@@ -57,7 +53,7 @@ tileDock.place(mySprite)
|
|
|
57
53
|
|
|
58
54
|
## See also #seealso
|
|
59
55
|
|
|
60
|
-
[get tile](/reference/
|
|
56
|
+
[get tile](/reference/color-coded-tilemap/get-tile)
|
|
61
57
|
|
|
62
58
|
```package
|
|
63
59
|
color-coded-tilemap
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# set Tile At
|
|
2
|
+
|
|
3
|
+
Change a tile in the tilemap to another tile.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
scene.setTileAt(null, 0)
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
A tile from the tile map has the [tile](/reference/color-coded-tilemap/tile) type. You can change that tile by using its object type, [tile](/reference/color-coded-tilemap/tile), and the index of a different tile. The tile map is changed to have the new tile take the position in the tilemap where this one was.
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
* **tile**: the [tile](/reference/color-coded-tilemap/tile) object to be replaced.
|
|
14
|
+
* **index**: the color index of the tile to replace the previous one.
|
|
15
|
+
|
|
16
|
+
## Example #example
|
|
17
|
+
|
|
18
|
+
Make a scene using a tilemap with border tiles and two tiles in the center. Replace the tiles in the center with the ones used for the border.
|
|
19
|
+
|
|
20
|
+
```blocks
|
|
21
|
+
scene.setTile(2, img`
|
|
22
|
+
a a a a a a a a a a a a a a a a
|
|
23
|
+
a a a a a a a a a a a a a a a a
|
|
24
|
+
a a a a a a a a a a a a a a a a
|
|
25
|
+
a a a a a a a a a a a a a a a a
|
|
26
|
+
a a a a a a a a a a a a a a a a
|
|
27
|
+
a a a a a a a a a a a a a a a a
|
|
28
|
+
a a a a a a a a a a a a a a a a
|
|
29
|
+
a a a a a a a a a a a a a a a a
|
|
30
|
+
a a a a a a a a a a a a a a a a
|
|
31
|
+
a a a a a a a a a a a a a a a a
|
|
32
|
+
a a a a a a a a a a a a a a a a
|
|
33
|
+
a a a a a a a a a a a a a a a a
|
|
34
|
+
a a a a a a a a a a a a a a a a
|
|
35
|
+
a a a a a a a a a a a a a a a a
|
|
36
|
+
a a a a a a a a a a a a a a a a
|
|
37
|
+
a a a a a a a a a a a a a a a a
|
|
38
|
+
`)
|
|
39
|
+
scene.setTileMap(img`
|
|
40
|
+
2 2 2 2 2 2 2 2 2 2
|
|
41
|
+
2 . . . . . . . . 2
|
|
42
|
+
2 . . . . . . . . 2
|
|
43
|
+
2 . . . 1 1 . . . 2
|
|
44
|
+
2 . . . . . . . . 2
|
|
45
|
+
2 . . . . . . . . 2
|
|
46
|
+
2 2 2 2 2 2 2 2 2 2
|
|
47
|
+
. . . . . . . . . .
|
|
48
|
+
`)
|
|
49
|
+
pause(1000)
|
|
50
|
+
scene.setTileAt(scene.getTile(4, 3), 2)
|
|
51
|
+
pause(1000)
|
|
52
|
+
scene.setTileAt(scene.getTile(5, 3), 2)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## See also #seealso
|
|
56
|
+
|
|
57
|
+
[set tile](/reference/color-coded-tilemap/set-tile), [get tile](/reference/color-coded-tilemap/get-tile)
|
|
58
|
+
|
|
59
|
+
```package
|
|
60
|
+
color-coded-tilemap
|
|
61
|
+
```
|
|
@@ -6,7 +6,7 @@ Arrange image tiles as a pattern in the scene.
|
|
|
6
6
|
scene.setTileMap(null)
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Your game scene contains a [tile map](/reference/
|
|
9
|
+
Your game scene contains a [tile map](/reference/color-coded-tilemap/tile-map). A tile map is an arrangement (a pattern) of image tiles that fill up some of the scene. At first, the scene has an empty tile map and no tile pattern is displayed. To build up your scene, you need to make some tiles, add them to the scene, and then tell the scene where to place the tiles.
|
|
10
10
|
|
|
11
11
|
The tile map uses an image layout to map the tiles for the scene. The color numbers in the image are identifiers (an index) for image tiles that were added to the scene. Tile indexes are placed at various locations in the map to create what's displayed in the scene. If there's no tile set with an index to match a color number in the map, the actual color for that number is filled into the scene at that tile location instead.
|
|
12
12
|
|
|
@@ -77,8 +77,8 @@ scene.setTileMap(img`
|
|
|
77
77
|
|
|
78
78
|
## See also #seealso
|
|
79
79
|
|
|
80
|
-
[tile map](/reference/
|
|
81
|
-
[set tile](/reference/
|
|
80
|
+
[tile map](/reference/color-coded-tilemap/tile-map),
|
|
81
|
+
[set tile](/reference/color-coded-tilemap/set-tile)
|
|
82
82
|
|
|
83
83
|
```package
|
|
84
84
|
color-coded-tilemap
|
|
@@ -60,7 +60,7 @@ scene.setTileMap(img`
|
|
|
60
60
|
|
|
61
61
|
## See also #seealso
|
|
62
62
|
|
|
63
|
-
[tile map](/reference/
|
|
63
|
+
[tile map](/reference/color-coded-tilemap/tile-map), [set tile map](/reference/color-coded-tilemap/set-tile-map)
|
|
64
64
|
|
|
65
65
|
```package
|
|
66
66
|
color-coded-tilemap
|
|
@@ -167,8 +167,8 @@ scene.setTileMap(img`
|
|
|
167
167
|
|
|
168
168
|
## See also #seealso
|
|
169
169
|
|
|
170
|
-
[set tile](/reference/
|
|
171
|
-
[set tile map](/reference/
|
|
170
|
+
[set tile](/reference/color-coded-tilemap/set-tile),
|
|
171
|
+
[set tile map](/reference/color-coded-tilemap/set-tile-map)
|
|
172
172
|
|
|
173
173
|
```package
|
|
174
174
|
color-coded-tilemap
|
package/libs/{game/docs/types → color-coded-tilemap/docs/reference/color-coded-tilemap}/tile.md
RENAMED
|
@@ -4,7 +4,7 @@ A tile is an image that is displayed as a rectangular portion of the game scene.
|
|
|
4
4
|
|
|
5
5
|
## The tile type
|
|
6
6
|
|
|
7
|
-
A **tile** is a complex type that contains an [image](/types/image) and a position in a tilemap. The game scene has a collection of tiles and they are added to the scene using the [setTile](/reference/
|
|
7
|
+
A **tile** is a complex type that contains an [image](/types/image) and a position in a tilemap. The game scene has a collection of tiles and they are added to the scene using the [setTile](/reference/color-coded-tilemap/set-tile) function. Tiles can also be set as a wall to keep sprites from passing through them.
|
|
8
8
|
|
|
9
9
|
## Setting tiles
|
|
10
10
|
|
|
@@ -68,7 +68,11 @@ tileList = scene.getTilesByType(4)
|
|
|
68
68
|
|
|
69
69
|
## See also
|
|
70
70
|
|
|
71
|
-
[set tile](/reference/
|
|
72
|
-
[set
|
|
73
|
-
[get tile](/reference/
|
|
74
|
-
[get tiles by type](/reference/
|
|
71
|
+
[set tile](/reference/color-coded-tilemap/set-tile),
|
|
72
|
+
[set tile map](/reference/color-coded-tilemap/set-tile-map),
|
|
73
|
+
[get tile](/reference/color-coded-tilemap/get-tile),
|
|
74
|
+
[get tiles by type](/reference/color-coded-tilemap/get-tiles-by-type)
|
|
75
|
+
|
|
76
|
+
```package
|
|
77
|
+
color-coded-tilemap
|
|
78
|
+
```
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Color Coded Tilemap
|
|
2
|
+
|
|
3
|
+
Map scene background tiles using color code placement.
|
|
4
|
+
|
|
5
|
+
## Tiles and Tilemaps
|
|
6
|
+
|
|
7
|
+
```cards
|
|
8
|
+
scene.setTileMap(null)
|
|
9
|
+
scene.getTile(0, 0)
|
|
10
|
+
scene.getTilesByType(0)
|
|
11
|
+
scene.getTile(0, 0).place(null)
|
|
12
|
+
scene.setTile(0, null)
|
|
13
|
+
scene.setTileAt(null, 0)
|
|
14
|
+
scene.onHitTile(0, 0, function (sprite) {
|
|
15
|
+
scene.placeOnRandomTile(null, 0)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## See also
|
|
19
|
+
|
|
20
|
+
[set tile](/reference/color-coded-tilemap/set-tile),
|
|
21
|
+
[set tile map](/reference/color-coded-tilemap/set-tile-map),
|
|
22
|
+
[set tile at](/reference/color-coded-tilemap/set-tile-at),
|
|
23
|
+
[get tile](/reference/color-coded-tilemap/get-tile),
|
|
24
|
+
[get tiles by type](/reference/color-coded-tilemap/get-tiles-by-type),
|
|
25
|
+
[place](/reference/scene/place),
|
|
26
|
+
[place on random tile](/reference/color-coded-tilemap/place-on-random-tile),
|
|
27
|
+
[on hit tile](/reference/color-coded-tilemap/on-hit-tile),
|
|
28
|
+
[tile hit from](/reference/sprites/sprite/tile-hit-from)
|
|
29
|
+
|
|
30
|
+
```package
|
|
31
|
+
color-coded-tilemap
|
|
32
|
+
```
|
|
@@ -12,7 +12,7 @@ namespace scene {
|
|
|
12
12
|
//% blockId=gamesettilemap block="set tile map to %map=tilemap_image_picker || with %scale pixel tiles"
|
|
13
13
|
//% scale.defl=TileScale.Sixteen
|
|
14
14
|
//% group="Color-coded Tilemap"
|
|
15
|
-
//% help=
|
|
15
|
+
//% help=color-coded-tilemap/set-tile-map
|
|
16
16
|
export function setTileMap(map: Image, scale = TileScale.Sixteen) {
|
|
17
17
|
const scene = game.currentScene();
|
|
18
18
|
if (!scene.tileMap || !(scene.tileMap as tiles.legacy.LegacyTilemap).isLegacy) {
|
|
@@ -29,7 +29,7 @@ namespace scene {
|
|
|
29
29
|
*/
|
|
30
30
|
//% blockId=gamesettile block="set tile %index=colorindexpicker to %img=tile_image_picker with wall %wall=toggleOnOff"
|
|
31
31
|
//% group="Color-coded Tilemap"
|
|
32
|
-
//% help=
|
|
32
|
+
//% help=color-coded-tilemap/set-tile
|
|
33
33
|
export function setTile(index: number, img: Image, wall?: boolean) {
|
|
34
34
|
const scene = game.currentScene();
|
|
35
35
|
if (!scene.tileMap || !(scene.tileMap as tiles.legacy.LegacyTilemap).isLegacy) {
|
|
@@ -45,7 +45,7 @@ namespace scene {
|
|
|
45
45
|
*/
|
|
46
46
|
//% blockId=gamegettile block="tile col %col row %row"
|
|
47
47
|
//% group="Color-coded Tilemap" blockSetVariable="myTile"
|
|
48
|
-
//% help=
|
|
48
|
+
//% help=color-coded-tilemap/get-tile
|
|
49
49
|
export function getTile(col: number, row: number): tiles.Tile {
|
|
50
50
|
const scene = game.currentScene();
|
|
51
51
|
if (!scene.tileMap || !(scene.tileMap as tiles.legacy.LegacyTilemap).isLegacy) {
|
|
@@ -60,7 +60,7 @@ namespace scene {
|
|
|
60
60
|
*/
|
|
61
61
|
//% blockId=gamegettilestype block="array of all %index=colorindexpicker tiles"
|
|
62
62
|
//% group="Color-coded Tilemap" blockSetVariable="tile list"
|
|
63
|
-
//% help=
|
|
63
|
+
//% help=color-coded-tilemap/get-tiles-by-type
|
|
64
64
|
export function getTilesByType(index: number): tiles.Tile[] {
|
|
65
65
|
const scene = game.currentScene();
|
|
66
66
|
if (!scene.tileMap || !(scene.tileMap as tiles.legacy.LegacyTilemap).isLegacy) {
|
|
@@ -77,7 +77,7 @@ namespace scene {
|
|
|
77
77
|
//% blockId=gameplaceonrandomtile block="place %sprite=variables_get(mySprite) on top of random $color tile"
|
|
78
78
|
//% group="Color-coded Tilemap"
|
|
79
79
|
//% color.shadow="colorindexpicker"
|
|
80
|
-
//% help=
|
|
80
|
+
//% help=color-coded-tilemap/place-on-random-tile
|
|
81
81
|
export function placeOnRandomTile(sprite: Sprite, color: number): void {
|
|
82
82
|
if (!sprite || !game.currentScene().tileMap) return;
|
|
83
83
|
const tiles = getTilesByType(color);
|
|
@@ -92,7 +92,7 @@ namespace scene {
|
|
|
92
92
|
*/
|
|
93
93
|
//% blockId=gamesettileat block="set %tile=gamegettile to %index=colorindexpicker"
|
|
94
94
|
//% group="Color-coded Tilemap"
|
|
95
|
-
//% help=
|
|
95
|
+
//% help=color-coded-tilemap/set-tile-at
|
|
96
96
|
export function setTileAt(tile: tiles.Tile, index: number) {
|
|
97
97
|
const scene = game.currentScene();
|
|
98
98
|
if (!scene.tileMap || !(scene.tileMap as tiles.legacy.LegacyTilemap).isLegacy) {
|
|
@@ -125,7 +125,7 @@ namespace scene {
|
|
|
125
125
|
//% group="Color-coded Tilemap"
|
|
126
126
|
//% draggableParameters="reporter"
|
|
127
127
|
//% blockId=spritesollisions block="on $sprite of kind $kind=spritekind hits wall $tile=colorindexpicker"
|
|
128
|
-
//% help=
|
|
128
|
+
//% help=color-coded-tilemap/on-hit-tile
|
|
129
129
|
export function onHitTile(kind: number, tile: number, handler: (sprite: Sprite) => void) {
|
|
130
130
|
if (kind == undefined || tile < 0 || tile > 0xF || !handler) return;
|
|
131
131
|
|
|
@@ -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___P96873(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___97116 = (undefined);
|
|
70
|
+
globals._pollEventQueue___97129 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P96873.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tcs34725.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P96873.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P96873_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P96873, 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___P96771_mk(s) {
|
|
|
88
88
|
|
|
89
89
|
const breakpoints = setupDebugger(1, [])
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return _main___P96873
|
|
92
92
|
})
|