pxt-common-packages 9.4.1 → 9.4.2

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.
Files changed (51) hide show
  1. package/libs/azureiot/built/debug/binary.js +461 -461
  2. package/libs/color/built/debug/binary.js +8 -8
  3. package/libs/color-sensor/built/debug/binary.js +8 -8
  4. package/libs/controller/built/debug/binary.js +7126 -6975
  5. package/libs/controller---none/built/debug/binary.js +7105 -6954
  6. package/libs/core---esp32/pins.cpp +30 -4
  7. package/libs/core---esp32/shims.d.ts +15 -0
  8. package/libs/core---esp32s2/shims.d.ts +15 -0
  9. package/libs/datalogger/built/debug/binary.js +63 -63
  10. package/libs/edge-connector/built/debug/binary.js +8 -8
  11. package/libs/esp32/built/debug/binary.js +462 -462
  12. package/libs/game/_locales/game-jsdoc-strings.json +10 -1
  13. package/libs/game/_locales/game-strings.json +18 -2
  14. package/libs/game/assetTemplates.ts +2 -0
  15. package/libs/game/built/debug/binary.js +7018 -6867
  16. package/libs/game/docs/reference/scene/get-tile-location.md +96 -0
  17. package/libs/game/docs/reference/scene/get-tiles-by-type.md +64 -43
  18. package/libs/game/docs/reference/scene/is-hitting-tile.md +87 -0
  19. package/libs/game/docs/reference/scene/on-hit-wall.md +88 -0
  20. package/libs/game/docs/reference/scene/on-overlap-tile.md +88 -0
  21. package/libs/game/docs/reference/scene/place-on-random-tile.md +95 -41
  22. package/libs/game/docs/reference/scene/place-on-tile.md +88 -0
  23. package/libs/game/docs/reference/scene/set-tile-at.md +45 -41
  24. package/libs/game/docs/reference/scene/set-wall-at.md +86 -0
  25. package/libs/game/docs/reference/scene/tile-at-location-equals.md +97 -0
  26. package/libs/game/docs/reference/scene/tile-kind-at.md +118 -0
  27. package/libs/game/docs/reference/scene.md +18 -16
  28. package/libs/game/physics.ts +1 -1
  29. package/libs/game/scenes.ts +5 -1
  30. package/libs/game/sprite.ts +23 -6
  31. package/libs/game/spriteevents.ts +7 -7
  32. package/libs/game/sprites.ts +16 -0
  33. package/libs/game/tilemap.ts +172 -26
  34. package/libs/lcd/built/debug/binary.js +8 -8
  35. package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
  36. package/libs/lora/built/debug/binary.js +8 -8
  37. package/libs/matrix-keypad/built/debug/binary.js +8 -8
  38. package/libs/mqtt/built/debug/binary.js +176 -176
  39. package/libs/net/built/debug/binary.js +176 -176
  40. package/libs/net-game/built/debug/binary.js +8802 -8651
  41. package/libs/palette/built/debug/binary.js +7017 -6866
  42. package/libs/pixel/built/debug/binary.js +8 -8
  43. package/libs/power/built/debug/binary.js +8 -8
  44. package/libs/proximity/built/debug/binary.js +8 -8
  45. package/libs/radio/built/debug/binary.js +8 -8
  46. package/libs/radio-broadcast/built/debug/binary.js +8 -8
  47. package/libs/rotary-encoder/built/debug/binary.js +8 -8
  48. package/libs/screen/built/debug/binary.js +50 -50
  49. package/libs/servo/built/debug/binary.js +8 -8
  50. package/libs/storyboard/built/debug/binary.js +7017 -6866
  51. package/package.json +1 -1
@@ -0,0 +1,88 @@
1
+ # place On Tile
2
+
3
+ Move a sprite's position to the center of a tile location in the tilemap.
4
+
5
+ ```sig
6
+ tiles.placeOnTile(null, tiles.getTileLocation(0, 0))
7
+ ```
8
+
9
+ A sprite will locate itself on top of a tile in the tilemap using a tilemap location object. A location object contains a tile row value and a tile column value.
10
+
11
+ ## Parameters
12
+
13
+ * **sprite**: the sprite to move onto the tile.
14
+ * **loc**: a tile location in the tilemap.
15
+
16
+ ## Example #example
17
+
18
+ Make a grid tilemap with two tile colors. Create a round shaped sprite. Ramdomly place the sprite on a tile in the grid.
19
+
20
+ ```blocks
21
+ tiles.setTilemap(tilemap`level1`)
22
+ let mySprite = sprites.create(img`
23
+ . . . . . . . . . . . . . . . .
24
+ . . . . . . . . . . . . . . . .
25
+ . . . . . 7 7 7 7 7 7 . . . . .
26
+ . . . 7 7 7 7 7 7 7 7 7 7 . . .
27
+ . . . 7 7 7 7 7 7 7 7 7 7 . . .
28
+ . . 7 7 7 7 7 7 7 7 7 7 7 7 . .
29
+ . . 7 7 7 7 7 7 7 7 7 7 7 7 . .
30
+ . . 7 7 7 7 7 7 7 7 7 7 7 7 . .
31
+ . . 7 7 7 7 7 7 7 7 7 7 7 7 . .
32
+ . . 7 7 7 7 7 7 7 7 7 7 7 7 . .
33
+ . . 7 7 7 7 7 7 7 7 7 7 7 7 . .
34
+ . . . 7 7 7 7 7 7 7 7 7 7 . . .
35
+ . . . 7 7 7 7 7 7 7 7 7 7 . . .
36
+ . . . . . 7 7 7 7 7 7 . . . . .
37
+ . . . . . . . . . . . . . . . .
38
+ . . . . . . . . . . . . . . . .
39
+ `, SpriteKind.Player)
40
+
41
+ forever(function () {
42
+ tiles.placeOnTile(mySprite, tiles.getTileLocation(randint(0, 9), randint(0, 6)))
43
+ pause(500)
44
+ })
45
+ ```
46
+
47
+ ## See also #seealso
48
+
49
+ [get tile location](/reference/scene/get-tile-location),
50
+ [place on random tile](/reference/scene/place-on-random-tile)
51
+
52
+ ```jres
53
+ {
54
+ "transparency16": {
55
+ "data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
56
+ "mimeType": "image/x-mkcd-f4",
57
+ "tilemapTile": true
58
+ },
59
+ "tile1": {
60
+ "data": "hwQQABAAAADd3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3Q==",
61
+ "mimeType": "image/x-mkcd-f4",
62
+ "tilemapTile": true,
63
+ "displayName": "myTile"
64
+ },
65
+ "tile2": {
66
+ "data": "hwQQABAAAABVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVQ==",
67
+ "mimeType": "image/x-mkcd-f4",
68
+ "tilemapTile": true,
69
+ "displayName": "myTile0"
70
+ },
71
+ "level1": {
72
+ "id": "level1",
73
+ "mimeType": "application/mkcd-tilemap",
74
+ "data": "MTAwYTAwMDgwMDAxMDIwMTAyMDEwMjAxMDIwMTAyMDIwMTAyMDEwMjAxMDIwMTAyMDEwMTAyMDEwMjAxMDIwMTAyMDEwMjAyMDEwMjAxMDIwMTAyMDEwMjAxMDEwMjAxMDIwMTAyMDEwMjAxMDIwMjAxMDIwMTAyMDEwMjAxMDIwMTAxMDIwMTAyMDEwMjAxMDIwMTAyMDIwMTAyMDEwMjAxMDIwMTAyMDEwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMA==",
75
+ "tileset": [
76
+ "myTiles.transparency16",
77
+ "myTiles.tile1",
78
+ "myTiles.tile2"
79
+ ],
80
+ "displayName": "level1"
81
+ },
82
+ "*": {
83
+ "mimeType": "image/x-mkcd-f4",
84
+ "dataEncoding": "base64",
85
+ "namespace": "myTiles"
86
+ }
87
+ }
88
+ ```
@@ -1,61 +1,65 @@
1
1
  # set Tile At
2
2
 
3
- Change a tile in the tilemap to another tile.
3
+ Set a tile at a location in the tilemap.
4
4
 
5
5
  ```sig
6
- scene.setTileAt(null, 0)
6
+ tiles.setTileAt(null, tiles.getTileLocation(0, 0))
7
7
  ```
8
8
 
9
- A tile from the tile map has the [tile](/types/tile) type. You can change that tile by using it's object type, [tile](/types/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.
9
+ You can set a tile at a specific column and row in the tilemap using a tile location object. Specify a tile to set in the tilemap and a location for it.
10
10
 
11
11
  ## Parameters
12
12
 
13
- * **tile**: the [tile](/types/tile) object to be replaced.
14
- * **index**: the color index of the tile to replace the previous one.
13
+ * **tile**: the to set in the tilemap.
14
+ * **loc**: a tile location in the tilemap.
15
15
 
16
16
  ## Example #example
17
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.
18
+ Create an empty tilemap and a solid color tile. Set the solid color tile at different places in the tilemap and replace its previous location with a transparent tile.
19
19
 
20
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)
21
+ tiles.setTilemap(tilemap`level1`)
22
+ let spot = tiles.getTileLocation(0, 0)
23
+ forever(function () {
24
+ tiles.setTileAt(spot, assets.tile`transparency16`)
25
+ spot = tiles.getTileLocation(randint(0, 9), randint(0, 6))
26
+ tiles.setTileAt(spot, assets.tile`myTile`)
27
+ pause(1000)
28
+ })
53
29
  ```
54
30
 
55
31
  ## See also #seealso
56
32
 
57
- [set tile](/reference/scene/set-tile), [get tile](/reference/scene/get-tile)
33
+ [get tile location](/reference/scene/get-tile-location),
34
+ [place on tile](/reference/scene/place-on-tile)
58
35
 
59
- ```package
60
- color-coded-tilemap
36
+ ```jres
37
+ {
38
+ "transparency16": {
39
+ "data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
40
+ "mimeType": "image/x-mkcd-f4",
41
+ "tilemapTile": true
42
+ },
43
+ "tile1": {
44
+ "data": "hwQQABAAAABERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERA==",
45
+ "mimeType": "image/x-mkcd-f4",
46
+ "tilemapTile": true,
47
+ "displayName": "myTile"
48
+ },
49
+ "level1": {
50
+ "id": "level1",
51
+ "mimeType": "application/mkcd-tilemap",
52
+ "data": "MTAwYTAwMDgwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMA==",
53
+ "tileset": [
54
+ "myTiles.transparency16",
55
+ "myTiles.tile1"
56
+ ],
57
+ "displayName": "level1"
58
+ },
59
+ "*": {
60
+ "mimeType": "image/x-mkcd-f4",
61
+ "dataEncoding": "base64",
62
+ "namespace": "myTiles"
63
+ }
64
+ }
61
65
  ```
@@ -0,0 +1,86 @@
1
+ # set Wall At
2
+
3
+ Set a tile as a wall tile in the tilemap.
4
+
5
+ ```sig
6
+ tiles.setWallAt(tiles.getTileLocation(0, 0), false)
7
+ ```
8
+
9
+ Wall tiles create a barrier for sprites so that they can't pass through tilemap at the tile location. You can set a tile location in the tilemap as a wall or turn it back to a regular tile.
10
+
11
+ ## Parameters
12
+
13
+ * **loc**: a tile location in the tilemap.
14
+ * **on**: a [boolean](/types/boolean) value to set the tile location be a wall tile if `true` or a regular tile if `false`.
15
+
16
+ ## Example #example
17
+
18
+ Make a column of tiles from top to bottom of the screen. Set a sprite in motion and set it to bounce on walls. Every `5` seconds, set the tiles in the column to be wall tiles or regular tiles.
19
+
20
+ ```blocks
21
+ let isWall = false
22
+ tiles.setTilemap(tilemap`level1`)
23
+ let mySprite = sprites.create(img`
24
+ . . . . . . . . . . . . . . . .
25
+ . . . . . . . . . . . . . . . .
26
+ . . . . . 1 1 1 1 1 1 . . . . .
27
+ . . . 1 1 2 2 2 2 2 2 1 1 . . .
28
+ . . . 1 2 2 2 2 2 2 2 2 1 . . .
29
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
30
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
31
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
32
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
33
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
34
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
35
+ . . . 1 2 2 2 2 2 2 2 2 1 . . .
36
+ . . . 1 1 2 2 2 2 2 2 1 1 . . .
37
+ . . . . . 1 1 1 1 1 1 . . . . .
38
+ . . . . . . . . . . . . . . . .
39
+ . . . . . . . . . . . . . . . .
40
+ `, SpriteKind.Player)
41
+ mySprite.setBounceOnWall(true)
42
+ mySprite.vx = 80
43
+ mySprite.vy = 70
44
+ game.onUpdateInterval(5000, function () {
45
+ isWall = !(isWall)
46
+ for (let wallTile of tiles.getTilesByType(assets.tile`myTile`)) {
47
+ tiles.setWallAt(wallTile, isWall)
48
+ }
49
+ })
50
+ ```
51
+
52
+ ## See also #seealso
53
+
54
+ [get tile location](/reference/scene/get-tile-location),
55
+ [on hit wall](/reference/scene/on-hit-wall)
56
+
57
+ ```jres
58
+ {
59
+ "transparency16": {
60
+ "data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
61
+ "mimeType": "image/x-mkcd-f4",
62
+ "tilemapTile": true
63
+ },
64
+ "tile1": {
65
+ "data": "hwQQABAAAADu7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7g==",
66
+ "mimeType": "image/x-mkcd-f4",
67
+ "tilemapTile": true,
68
+ "displayName": "myTile"
69
+ },
70
+ "level1": {
71
+ "id": "level1",
72
+ "mimeType": "application/mkcd-tilemap",
73
+ "data": "MTAwYTAwMDgwMDAwMDAwMDAwMDEwMDAwMDAwMDAwMDAwMDAwMDAwMDAxMDAwMDAwMDAwMDAwMDAwMDAxMDAwMDAwMDAwMDAwMDAwMDAwMDAwMTAwMDAwMDAwMDAwMDAwMDAwMTAwMDAwMDAwMDAwMDAwMDAwMDAwMDEwMDAwMDAwMDAwMDAwMDAwMDEwMDAwMDAwMDAwMDAwMDAwMDAwMDAxMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMA==",
74
+ "tileset": [
75
+ "myTiles.transparency16",
76
+ "myTiles.tile1"
77
+ ],
78
+ "displayName": "level1"
79
+ },
80
+ "*": {
81
+ "mimeType": "image/x-mkcd-f4",
82
+ "dataEncoding": "base64",
83
+ "namespace": "myTiles"
84
+ }
85
+ }
86
+ ```
@@ -0,0 +1,97 @@
1
+ # tile At Location Equals
2
+
3
+ Check if a location in the tilemap contains the tile you're looking for.
4
+
5
+ ```sig
6
+ tiles.tileAtLocationEquals(location, null)
7
+ ```
8
+
9
+ ## Parameters
10
+
11
+ * **location**: a location in the tilemap.
12
+ * **tile**: an [image](/types/image) that matches the tile you're looking for.
13
+
14
+ ## Returns
15
+
16
+ * a [boolean](/types/boolean) value that is `true` if the tile at **location** matches the **tile** you want to check for. If not, `false` is returned.
17
+
18
+ ## Example #example
19
+
20
+ Make a tilemap with two columns of wall tiles with a different color for each. Set a sprite in motion and cause it to bounce on walls. When the sprite contacts a tile, check to see what color the tile is.
21
+
22
+ ```blocks
23
+ scene.onHitWall(SpriteKind.Player, function (sprite, location) {
24
+ if (tiles.tileAtLocationEquals(location, assets.tile`myTile0`)) {
25
+ mySprite.sayText("Blue", 500, false)
26
+ } else if (tiles.tileAtLocationEquals(location, assets.tile`myTile1`)) {
27
+ mySprite.sayText("Green", 500, false)
28
+ } else {
29
+ mySprite.startEffect(effects.fire, 200)
30
+ }
31
+ })
32
+ let mySprite: Sprite = null
33
+ tiles.setTilemap(tilemap`level1`)
34
+ mySprite = sprites.create(img`
35
+ . . . . . . . . . . . . . . . .
36
+ . . . . . . . . . . . . . . . .
37
+ . . . . . 1 1 1 1 1 1 . . . . .
38
+ . . . 1 1 2 2 2 2 2 2 1 1 . . .
39
+ . . . 1 2 2 2 2 2 2 2 2 1 . . .
40
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
41
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
42
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
43
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
44
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
45
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
46
+ . . . 1 2 2 2 2 2 2 2 2 1 . . .
47
+ . . . 1 1 2 2 2 2 2 2 1 1 . . .
48
+ . . . . . 1 1 1 1 1 1 . . . . .
49
+ . . . . . . . . . . . . . . . .
50
+ . . . . . . . . . . . . . . . .
51
+ `, SpriteKind.Player)
52
+ mySprite.setBounceOnWall(true)
53
+ mySprite.vx = 40
54
+ mySprite.vy = 35
55
+ ```
56
+
57
+ ## See also #seealso
58
+
59
+ [get tile location](/reference/scene/get-tile-location)
60
+
61
+ ```jres
62
+ {
63
+ "transparency16": {
64
+ "data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
65
+ "mimeType": "image/x-mkcd-f4",
66
+ "tilemapTile": true
67
+ },
68
+ "tile1": {
69
+ "data": "hwQQABAAAACIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiA==",
70
+ "mimeType": "image/x-mkcd-f4",
71
+ "tilemapTile": true,
72
+ "displayName": "myTile0"
73
+ },
74
+ "tile2": {
75
+ "data": "hwQQABAAAAB3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3dw==",
76
+ "mimeType": "image/x-mkcd-f4",
77
+ "tilemapTile": true,
78
+ "displayName": "myTile1"
79
+ },
80
+ "level1": {
81
+ "id": "level1",
82
+ "mimeType": "application/mkcd-tilemap",
83
+ "data": "MTAwYTAwMDgwMDAyMDAwMDAwMDAwMDAwMDAwMDAxMDIwMDAwMDAwMDAwMDAwMDAwMDEwMjAwMDAwMDAwMDAwMDAwMDAwMTAyMDAwMDAwMDAwMDAwMDAwMDAxMDIwMDAwMDAwMDAwMDAwMDAwMDEwMjAwMDAwMDAwMDAwMDAwMDAwMTAyMDAwMDAwMDAwMDAwMDAwMDAxMDIwMDAwMDAwMDAwMDAwMDAwMDEwMjAwMDAwMDIwMDIwMDAwMDAyMDAyMDAwMDAwMjAwMjAwMDAwMDIwMDIwMDAwMDAyMDAyMDAwMDAwMjAwMjAwMDAwMDIwMDIwMDAwMDAyMA==",
84
+ "tileset": [
85
+ "myTiles.transparency16",
86
+ "myTiles.tile1",
87
+ "myTiles.tile2"
88
+ ],
89
+ "displayName": "level1"
90
+ },
91
+ "*": {
92
+ "mimeType": "image/x-mkcd-f4",
93
+ "dataEncoding": "base64",
94
+ "namespace": "myTiles"
95
+ }
96
+ }
97
+ ```
@@ -0,0 +1,118 @@
1
+ # tile Kind At
2
+
3
+ Check if the tile next to a sprite is the one you're looking for.
4
+
5
+ ```sig
6
+ sprites.create(null).tileKindAt(TileDirection.Right, null)
7
+ ```
8
+
9
+ A tile next to a sprite can be matched to a tile you want to check for. You choose the direction to check for to see if the tile is next to the sprite. If the tile matches the one you are looking for in that direction, it will detect it when the sprite is within one-half of it's dimension for that direction.
10
+
11
+ ## Parameters
12
+
13
+ * **direction**: the direction from the sprite for the tile check: `left`, `right`, `top`, or `bottom`.
14
+ * **tile**: an [image](/types/image) that matches the tile you're looking for.
15
+
16
+ ## Returns
17
+
18
+ * a [boolean](/types/boolean) value that is `true` if the tile near the sprite at the **direction** matches the **tile** you want to check for. If not, `false` is returned.
19
+
20
+ ## Example #example
21
+
22
+ Make a tilemap with three columns of tiles with a different color for each. Set a sprite in motion from left to right. When the sprite comes near a tile, check to see what color the tile is.
23
+
24
+ ```blocks
25
+ tiles.setTilemap(tilemap`level1`)
26
+ let mySprite = sprites.create(img`
27
+ . . . . . . . . . . . . . . . .
28
+ . . . . . . . . . . . . . . . .
29
+ . . . . . 1 1 1 1 1 1 . . . . .
30
+ . . . 1 1 9 9 9 9 9 9 1 1 . . .
31
+ . . . 1 9 9 9 9 9 9 9 9 1 . . .
32
+ . . 1 9 9 9 9 9 9 9 9 9 9 1 . .
33
+ . . 1 9 9 9 9 9 9 9 9 9 9 1 . .
34
+ . . 1 9 9 9 9 9 9 9 9 9 9 1 . .
35
+ . . 1 9 9 9 9 9 9 9 9 9 9 1 . .
36
+ . . 1 9 9 9 9 9 9 9 9 9 9 1 . .
37
+ . . 1 9 9 9 9 9 9 9 9 9 9 1 . .
38
+ . . . 1 9 9 9 9 9 9 9 9 1 . . .
39
+ . . . 1 1 9 9 9 9 9 9 1 1 . . .
40
+ . . . . . 1 1 1 1 1 1 . . . . .
41
+ . . . . . . . . . . . . . . . .
42
+ . . . . . . . . . . . . . . . .
43
+ `, SpriteKind.Player)
44
+ mySprite.x = 0
45
+ game.onUpdateInterval(100, function () {
46
+ if (mySprite.tileKindAt(TileDirection.Right, assets.tile`myTile2`)) {
47
+ mySprite.sayText("red", 100, false)
48
+ } else if (mySprite.tileKindAt(TileDirection.Right, assets.tile`myTile1`)) {
49
+ mySprite.sayText("green", 100, false)
50
+ } else if (mySprite.tileKindAt(TileDirection.Right, assets.tile`myTile3`)) {
51
+ mySprite.sayText("yellow", 100, false)
52
+ } else if (mySprite.right >= scene.screenWidth()) {
53
+ mySprite.x = 0
54
+ }
55
+ mySprite.x += 2
56
+ })
57
+ ```
58
+
59
+ ## See also #seealso
60
+
61
+ [is hitting tile](/reference/scene/is-hitting-tile)
62
+
63
+ ```jres
64
+ {
65
+ "transparency16": {
66
+ "data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
67
+ "mimeType": "image/x-mkcd-f4",
68
+ "tilemapTile": true
69
+ },
70
+ "tile1": {
71
+ "data": "hwQQABAAAADu7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7g==",
72
+ "mimeType": "image/x-mkcd-f4",
73
+ "tilemapTile": true,
74
+ "displayName": "myTile"
75
+ },
76
+ "tile2": {
77
+ "data": "hwQQABAAAACIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiA==",
78
+ "mimeType": "image/x-mkcd-f4",
79
+ "tilemapTile": true,
80
+ "displayName": "myTile0"
81
+ },
82
+ "tile3": {
83
+ "data": "hwQQABAAAAB3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3dw==",
84
+ "mimeType": "image/x-mkcd-f4",
85
+ "tilemapTile": true,
86
+ "displayName": "myTile1"
87
+ },
88
+ "tile4": {
89
+ "data": "hwQQABAAAAAiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIg==",
90
+ "mimeType": "image/x-mkcd-f4",
91
+ "tilemapTile": true,
92
+ "displayName": "myTile2"
93
+ },
94
+ "tile5": {
95
+ "data": "hwQQABAAAABVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVQ==",
96
+ "mimeType": "image/x-mkcd-f4",
97
+ "tilemapTile": true,
98
+ "displayName": "myTile3"
99
+ },
100
+ "level1": {
101
+ "id": "level1",
102
+ "mimeType": "application/mkcd-tilemap",
103
+ "data": "MTAwYTAwMDgwMDAwMDAwMTAwMDAwMzAwMDAwMjAwMDAwMDAxMDAwMDAzMDAwMDAyMDAwMDAwMDEwMDAwMDMwMDAwMDIwMDAwMDAwMTAwMDAwMzAwMDAwMjAwMDAwMDAxMDAwMDAzMDAwMDAyMDAwMDAwMDEwMDAwMDMwMDAwMDIwMDAwMDAwMTAwMDAwMzAwMDAwMjAwMDAwMDAxMDAwMDAzMDAwMDAyMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMA==",
104
+ "tileset": [
105
+ "myTiles.transparency16",
106
+ "myTiles.tile3",
107
+ "myTiles.tile4",
108
+ "myTiles.tile5"
109
+ ],
110
+ "displayName": "level1"
111
+ },
112
+ "*": {
113
+ "mimeType": "image/x-mkcd-f4",
114
+ "dataEncoding": "base64",
115
+ "namespace": "myTiles"
116
+ }
117
+ }
118
+ ```
@@ -16,16 +16,17 @@ scene.backgroundImage()
16
16
  ## Tiles and Tilemaps
17
17
 
18
18
  ```cards
19
- scene.setTile(0, null)
20
- scene.setTileMap(null)
21
- scene.setTileAt(null, 0)
22
- scene.getTile(0, 0)
23
- scene.getTilesByType(0)
24
- scene.getTile(0, 0).place(null)
25
- scene.placeOnRandomTile(null, 0)
26
- scene.onHitTile(0, 0, function (sprite) {})
27
- sprites.create(null).isHittingTile(CollisionDirection.Left)
28
- sprites.create(null).tileHitFrom(CollisionDirection.Left)
19
+ tiles.setTileAt(null, tiles.getTileLocation(0, 0))
20
+ tiles.setWallAt(tiles.getTileLocation(0, 0), false)
21
+ tiles.getTileLocation(0, 0)
22
+ tiles.getTilesByType(null)
23
+ tiles.placeOnTile(null, tiles.getTileLocation(0, 0))
24
+ tiles.placeOnRandomTile(null, null)
25
+ scene.onOverlapTile(SpriteKind.Player, null, function (sprite, location) {})
26
+ scene.onHitWall(SpriteKind.Player, function (sprite, location) { })
27
+ tiles.tileAtLocationEquals(location, null)
28
+ sprites.create(null).isHittingTile(CollisionDirection.Right)
29
+ sprites.create(null).tileKindAt(TileDirection.Right, null)
29
30
  ```
30
31
 
31
32
  ## Screen Effects
@@ -51,16 +52,17 @@ scene.cameraShake(4,500)
51
52
  [set background image](/reference/scene/set-background-image),
52
53
  [background color](/reference/scene/background-color),
53
54
  [background image](/reference/scene/background-image),
54
- [set tile](/reference/scene/set-tile),
55
- [set tile map](/reference/scene/set-tile-map),
56
55
  [set tile at](/reference/scene/set-tile-at),
57
- [get tile](/reference/scene/get-tile),
56
+ [set wall at](/reference/scene/set-wall-at),
57
+ [get tile location](/reference/scene/get-tile-location),
58
58
  [get tiles by type](/reference/scene/get-tiles-by-type),
59
- [place](/reference/scene/place),
59
+ [place on tile](/reference/scene/place-on-tile,)
60
60
  [place on random tile](/reference/scene/place-on-random-tile),
61
- [on hit tile](/reference/scene/on-hit-tile),
61
+ [on overlap tile](/reference/scene/on-overlap-tile),
62
+ [on hit wall](/reference/scene/on-hit-wall),
63
+ [tile at location equals](/reference/scene/tile-at-location-equals),
62
64
  [is hitting tile](/reference/sprites/sprite-is-hittint-tile),
63
- [tile hit from](/reference/sprites/sprite/tile-hit-from),
65
+ [tile kind at](/reference/sprites/sprite/tile-kind-at),
64
66
  [start screen effect](/reference/scene/start-screen-effect),
65
67
  [end screen effect](/reference/scene/end-screen-effect),
66
68
  [camera follow sprite](/reference/scene/camera-follow-sprite),
@@ -597,7 +597,7 @@ class ArcadePhysicsEngine extends PhysicsEngine {
597
597
  const alreadyHandled: tiles.Location[] = [];
598
598
 
599
599
  for (const tile of overlappedTiles) {
600
- if (alreadyHandled.some(l => l.col === tile.col && l.row === tile.row)) {
600
+ if (alreadyHandled.some(l => l.column === tile.column && l.row === tile.row)) {
601
601
  continue;
602
602
  }
603
603
  alreadyHandled.push(tile);
@@ -18,7 +18,7 @@ enum CameraProperty {
18
18
  }
19
19
 
20
20
  //% weight=88 color="#4b6584" icon="\uf1bb"
21
- //% groups='["Screen", "Effects", "Tiles", "Collisions", "Camera"]'
21
+ //% groups='["Screen", "Camera", "Effects", "Tilemaps", "Tilemap Operations", "Locations"]'
22
22
  //% blockGap=8
23
23
  namespace scene {
24
24
  /**
@@ -128,6 +128,7 @@ namespace scene {
128
128
  //% duration.shadow=timePicker duration.defl=500
129
129
  //% group="Camera"
130
130
  //% help=scene/camera-shake
131
+ //% weight=90
131
132
  export function cameraShake(amplitude: number = 4, duration: number = 500) {
132
133
  const scene = game.currentScene();
133
134
  scene.camera.shake(amplitude, duration);
@@ -140,6 +141,7 @@ namespace scene {
140
141
  //% blockId=camerafollow block="camera follow sprite %sprite=variables_get(mySprite)"
141
142
  //% group="Camera"
142
143
  //% help=scene/camera-follow-sprite
144
+ //% weight=100
143
145
  export function cameraFollowSprite(sprite: Sprite) {
144
146
  const scene = game.currentScene();
145
147
  scene.camera.sprite = sprite;
@@ -152,6 +154,7 @@ namespace scene {
152
154
  //% blockId=camerapos block="center camera at x %x y %y"
153
155
  //% group="Camera"
154
156
  //% help=scene/center-camera-at
157
+ //% weight=80
155
158
  export function centerCameraAt(x: number, y: number) {
156
159
  const scene = game.currentScene();
157
160
  scene.camera.sprite = undefined;
@@ -190,6 +193,7 @@ namespace scene {
190
193
  //% blockId=cameraproperty block="camera $property"
191
194
  //% group="Camera"
192
195
  //% help=scene/camera-property
196
+ //% weight=70
193
197
  export function cameraProperty(property: CameraProperty): number {
194
198
  const scene = game.currentScene();
195
199
  switch (property) {
@@ -705,8 +705,9 @@ class Sprite extends sprites.BaseSprite {
705
705
  * @param direction
706
706
  */
707
707
  //% blockId=spritehasobstacle block="is %sprite(mySprite) hitting wall %direction"
708
- //% blockNamespace="scene" group="Collisions" blockGap=8
709
- //% help=sprites/sprite/is-hitting-tile
708
+ //% blockNamespace="scene" group="Locations" blockGap=24
709
+ //% help=scene/is-hitting-tile
710
+ //% weight=15
710
711
  isHittingTile(direction: CollisionDirection): boolean {
711
712
  return this._obstacles && !!this._obstacles[direction];
712
713
  }
@@ -717,8 +718,9 @@ class Sprite extends sprites.BaseSprite {
717
718
  */
718
719
  //% blockId=spritetileat block="tile to $direction of $this(mySprite) is $tile"
719
720
  //% tile.shadow=tileset_tile_picker
720
- //% blockNamespace="scene" group="Collisions" blockGap=8
721
- //% help=sprites/sprite/tile-kind-at
721
+ //% blockNamespace="scene" group="Locations" blockGap=8
722
+ //% help=scene/tile-kind-at
723
+ //% weight=20
722
724
  tileKindAt(direction: TileDirection, tile: Image): boolean {
723
725
  const tilemap = game.currentScene().tileMap;
724
726
  let x = this.x >> tilemap.scale;
@@ -748,13 +750,28 @@ class Sprite extends sprites.BaseSprite {
748
750
  * @param direction
749
751
  */
750
752
  //% blockId=spriteobstacle block="%sprite(mySprite) wall hit on %direction"
751
- //% blockNamespace="scene" group="Collisions"
753
+ //% blockNamespace="scene" group="Locations"
754
+ //% direction.shadow=tiles_collision_direction_editor
752
755
  //% help=sprites/sprite/tile-hit-from
753
756
  //% deprecated=1
754
- tileHitFrom(direction: CollisionDirection): number {
757
+ tileHitFrom(direction: number): number {
755
758
  return (this._obstacles && this._obstacles[direction]) ? this._obstacles[direction].tileIndex : -1;
756
759
  }
757
760
 
761
+ /**
762
+ * Gets the tilemap location at the center of a sprite
763
+ */
764
+ //% block="tilemap location of $this"
765
+ //% blockId=tiles_location_of_sprite
766
+ //% this.shadow=variables_get
767
+ //% this.defl=mySprite
768
+ //% blockNamespace="scene" group="Locations" weight=90
769
+ tilemapLocation(): tiles.Location {
770
+ const scene = game.currentScene();
771
+ if (!scene.tileMap) return undefined;
772
+ return tiles.getTileLocation(this.x >> scene.tileMap.scale, this.y >> scene.tileMap.scale);
773
+ }
774
+
758
775
  clearObstacles() {
759
776
  this._obstacles = [];
760
777
  }