pxt-common-packages 9.5.5 → 9.5.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.
@@ -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](/reference/tiles/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/tiles/get-tile-location),
50
+ [place on random tile](/reference/tiles/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
+ ```
@@ -0,0 +1,90 @@
1
+ # set Current Tilemap
2
+
3
+ Set a tilemap as the current tilemap for the game scene.
4
+
5
+ ```sig
6
+ tiles.setCurrentTilemap(null)
7
+ ```
8
+
9
+ A [tilemap](/reference/tiles/tilemap) is a data object that contains the dimensions, layers, and tile list for a tile mapping to set as the scene for a game. A game program can have more than one tilemap defined and the game's scene or _level_ can change by setting a different tilemap at certain times during a game.
10
+
11
+ Tilemaps aren't coded by the user but are created using a tilemap editor. Each tilemap in a game project is a named resource and is contained within the project's **assets** collection. In code,a particular tilemap is specified with it's resource name like this:
12
+
13
+ ```typescript
14
+ tiles.setCurrentTilemap(tilemap`level1`)
15
+ ```
16
+
17
+ ## Parameters
18
+
19
+ * **tilemap**: the [tilemap](/reference/tiles/tilemap) data containing the tilemap layout and tiles to set for the game scene. The tilemap can be specified by it's resource name, such as: `` tilemap`level1` ``.
20
+
21
+ ## Example #example
22
+
23
+ Create a maze tilemap for a sprite to travel through. Set the tilemap as the scene for the game. Create a sprite and start it travelling in the maze.
24
+
25
+ ```blocks
26
+ tiles.setCurrentTilemap(tilemap`level1`)
27
+ let mySprite = sprites.create(img`
28
+ . . . . . . . . . . . . . . . .
29
+ . . . . . . . . . . . . . . . .
30
+ . . . . . 5 5 5 5 5 5 . . . . .
31
+ . . . 5 5 5 5 5 5 5 5 5 5 . . .
32
+ . . . 5 5 5 5 5 5 5 5 5 5 . . .
33
+ . . 5 5 5 5 5 5 5 5 5 5 5 5 . .
34
+ . . 5 5 5 5 5 5 5 5 5 5 5 5 . .
35
+ . . 5 5 5 5 5 5 5 5 5 5 5 5 . .
36
+ . . 5 5 5 5 5 5 5 5 5 5 5 5 . .
37
+ . . 5 5 5 5 5 5 5 5 5 5 5 5 . .
38
+ . . 5 5 5 5 5 5 5 5 5 5 5 5 . .
39
+ . . . 5 5 5 5 5 5 5 5 5 5 . . .
40
+ . . . 5 5 5 5 5 5 5 5 5 5 . . .
41
+ . . . . . 5 5 5 5 5 5 . . . . .
42
+ . . . . . . . . . . . . . . . .
43
+ . . . . . . . . . . . . . . . .
44
+ `, SpriteKind.Player)
45
+ mySprite.setPosition(0, 104)
46
+ mySprite.vx = 16
47
+ ```
48
+
49
+ ## See also #seealso
50
+
51
+ [tilemap](/reference/tiles/tilemap),
52
+ [set tile at](/reference/scene/set-tile-at)
53
+
54
+ ```jres
55
+ {
56
+ "transparency16": {
57
+ "data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
58
+ "mimeType": "image/x-mkcd-f4",
59
+ "tilemapTile": true
60
+ },
61
+ "tile1": {
62
+ "data": "hwQQABAAAADu7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7g==",
63
+ "mimeType": "image/x-mkcd-f4",
64
+ "tilemapTile": true,
65
+ "displayName": "myTile0"
66
+ },
67
+ "tile2": {
68
+ "data": "hwQQABAAAABERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERA==",
69
+ "mimeType": "image/x-mkcd-f4",
70
+ "tilemapTile": true,
71
+ "displayName": "myTile1"
72
+ },
73
+ "level1": {
74
+ "id": "level1",
75
+ "mimeType": "application/mkcd-tilemap",
76
+ "data": "MTAwYTAwMDgwMDAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMDAwMDAwMDAwMDAwMDAwMDEwMTAwMDIwMjAyMDAwMjAyMDAwMTAxMDAwMjAwMDIwMDAyMDIwMDAwMDEwMDAyMDAwMjAwMDIwMDAwMDEwMTAwMDIwMDAyMDIwMjAwMDIwMTAwMDAwMDAwMDAwMDAyMDAwMDAxMDEwMTAxMDEwMTAxMDEwMTAxMDEyMjIyMjIyMjIyMDIwMDAwMDAyMDAyMjIwMjIyMjAwMjAyMDIyMjAwMDIwMjAyMDIyMDAyMDIyMjAyMjIwMDAwMDAwMjIwMjIyMjIyMjIyMg==",
77
+ "tileset": [
78
+ "myTiles.transparency16",
79
+ "myTiles.tile1",
80
+ "myTiles.tile2"
81
+ ],
82
+ "displayName": "maze"
83
+ },
84
+ "*": {
85
+ "mimeType": "image/x-mkcd-f4",
86
+ "dataEncoding": "base64",
87
+ "namespace": "myTiles"
88
+ }
89
+ }
90
+ ```
@@ -1,48 +1,65 @@
1
1
  # set Tile At
2
2
 
3
- Set a location in the tilemap to a specific tile.
3
+ Set a tile at a location in the tilemap.
4
4
 
5
5
  ```sig
6
- tiles.setTileAt(null, 0)
6
+ tiles.setTileAt(tiles.getTileLocation(0, 0), null)
7
7
  ```
8
8
 
9
- This block allows you to place a tile [image](/types/image) at a specific [tile](/types/tile) location in the map. The tile map will be updated with the new image.
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) location.
14
- * **image**: the tile [image](/types/image) to place in this location.
13
+ * **loc**: a tile [location](/reference/tiles/location) in the tilemap.
14
+ * **tile**: the to set 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
- let image = 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
- // TODO tiles.setTilemap(tiles.createTilemap(null, 0, 8 ** 8, 9));
40
- pause(1000)
41
- tiles.setTileAt(tiles.getTileLocation(4, 3), image)
42
- pause(1000)
43
- tiles.setTileAt(tiles.getTileLocation(5, 3), image)
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
+ })
44
29
  ```
45
30
 
46
31
  ## See also #seealso
47
32
 
48
- [set tile](/reference/tiles/set-tile), [get tile location](/reference/tiles/get-tile-location)
33
+ [get tile location](/reference/tiles/get-tile-location),
34
+ [place on tile](/reference/tiles/place-on-tile)
35
+
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
+ }
65
+ ```
@@ -0,0 +1,90 @@
1
+ # set Tilemap
2
+
3
+ Set a tilemap as the current tilemap for the game scene.
4
+
5
+ ```sig
6
+ tiles.setTilemap(null)
7
+ ```
8
+
9
+ A [tilemap](/reference/tiles/tilemap) is a data object that contains the dimensions, layers, and tile list for a tile mapping to set as the scene for a game. A game program can have more than one tilemap defined and the game's scene or _level_ can change by setting a different tilemap at certain times during a game.
10
+
11
+ Tilemaps aren't coded by the user but are created using a tilemap editor. Each tilemap in a game project is a named resource and is contained within the project's **assets** collection. In code, a particular tilemap is specified with it's resource name like this:
12
+
13
+ ```typescript
14
+ tiles.setTilemap(tilemap`level1`)
15
+ ```
16
+
17
+ ## Parameters
18
+
19
+ * **tilemap**: the [tilemap](/reference/tiles/tilemap) data containing the tilemap layout and tiles to set for the game scene. The tilemap can be specified by it's resource name, such as: `` tilemap`level1` ``.
20
+
21
+ ## Example #example
22
+
23
+ Create a maze tilemap for a sprite to travel through. Set the tilemap as the scene for the game. Create a sprite and start it travelling in the maze.
24
+
25
+ ```blocks
26
+ tiles.setTilemap(tilemap`level1`)
27
+ let mySprite = sprites.create(img`
28
+ . . . . . . . . . . . . . . . .
29
+ . . . . . . . . . . . . . . . .
30
+ . . . . . 5 5 5 5 5 5 . . . . .
31
+ . . . 5 5 5 5 5 5 5 5 5 5 . . .
32
+ . . . 5 5 5 5 5 5 5 5 5 5 . . .
33
+ . . 5 5 5 5 5 5 5 5 5 5 5 5 . .
34
+ . . 5 5 5 5 5 5 5 5 5 5 5 5 . .
35
+ . . 5 5 5 5 5 5 5 5 5 5 5 5 . .
36
+ . . 5 5 5 5 5 5 5 5 5 5 5 5 . .
37
+ . . 5 5 5 5 5 5 5 5 5 5 5 5 . .
38
+ . . 5 5 5 5 5 5 5 5 5 5 5 5 . .
39
+ . . . 5 5 5 5 5 5 5 5 5 5 . . .
40
+ . . . 5 5 5 5 5 5 5 5 5 5 . . .
41
+ . . . . . 5 5 5 5 5 5 . . . . .
42
+ . . . . . . . . . . . . . . . .
43
+ . . . . . . . . . . . . . . . .
44
+ `, SpriteKind.Player)
45
+ mySprite.setPosition(0, 104)
46
+ mySprite.vx = 16
47
+ ```
48
+
49
+ ## See also #seealso
50
+
51
+ [tilemap](/reference/tiles/tilemap),
52
+ [set tile at](/reference/scene/set-tile-at)
53
+
54
+ ```jres
55
+ {
56
+ "transparency16": {
57
+ "data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
58
+ "mimeType": "image/x-mkcd-f4",
59
+ "tilemapTile": true
60
+ },
61
+ "tile1": {
62
+ "data": "hwQQABAAAADu7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7g==",
63
+ "mimeType": "image/x-mkcd-f4",
64
+ "tilemapTile": true,
65
+ "displayName": "myTile0"
66
+ },
67
+ "tile2": {
68
+ "data": "hwQQABAAAABERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERA==",
69
+ "mimeType": "image/x-mkcd-f4",
70
+ "tilemapTile": true,
71
+ "displayName": "myTile1"
72
+ },
73
+ "level1": {
74
+ "id": "level1",
75
+ "mimeType": "application/mkcd-tilemap",
76
+ "data": "MTAwYTAwMDgwMDAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMDAwMDAwMDAwMDAwMDAwMDEwMTAwMDIwMjAyMDAwMjAyMDAwMTAxMDAwMjAwMDIwMDAyMDIwMDAwMDEwMDAyMDAwMjAwMDIwMDAwMDEwMTAwMDIwMDAyMDIwMjAwMDIwMTAwMDAwMDAwMDAwMDAyMDAwMDAxMDEwMTAxMDEwMTAxMDEwMTAxMDEyMjIyMjIyMjIyMDIwMDAwMDAyMDAyMjIwMjIyMjAwMjAyMDIyMjAwMDIwMjAyMDIyMDAyMDIyMjAyMjIwMDAwMDAwMjIwMjIyMjIyMjIyMg==",
77
+ "tileset": [
78
+ "myTiles.transparency16",
79
+ "myTiles.tile1",
80
+ "myTiles.tile2"
81
+ ],
82
+ "displayName": "maze"
83
+ },
84
+ "*": {
85
+ "mimeType": "image/x-mkcd-f4",
86
+ "dataEncoding": "base64",
87
+ "namespace": "myTiles"
88
+ }
89
+ }
90
+ ```
@@ -1,87 +1,86 @@
1
1
  # set Wall At
2
2
 
3
- Set a wall at a tile location in the tilemap.
3
+ Set a tile as a wall tile in the tilemap.
4
4
 
5
5
  ```sig
6
- tiles.setWallAt(null, false)
6
+ tiles.setWallAt(tiles.getTileLocation(0, 0), false)
7
7
  ```
8
8
 
9
- Tiles in a tilemap can serve as "wall" tiles to cause an action on a sprite that
10
- comes in contact with the tile. Sprites have flags ([boolean](/types/boolean)
11
- settings) that can set certain behavior when the contact a wall tile.
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.
12
10
 
13
11
  ## Parameters
14
12
 
15
- * **tile**: the [tile](/types/tile) location.
16
- * **on**: a [boolean](/types/boolean) value that sets the wall **ON** if `true` or **OFF** if `false` at the tile location.
13
+ * **loc**: a tile [location](/reference/tiles/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`.
17
15
 
18
16
  ## Example #example
19
17
 
20
- Create a scene with two horizontal walls. Bounce a sprite between the walls.
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.
21
19
 
22
20
  ```blocks
23
- namespace myTiles {
24
- //% blockIdentity=images._tile
25
- export const tile0 = img`
26
- . . . . . . . . . . . . . . . .
27
- . . . . . . . . . . . . . . . .
28
- . . . . . . . . . . . . . . . .
29
- . . . . . . . . . . . . . . . .
30
- . . . . . . . . . . . . . . . .
31
- . . . . . . . . . . . . . . . .
32
- . . . . . . . . . . . . . . . .
33
- . . . . . . . . . . . . . . . .
34
- . . . . . . . . . . . . . . . .
35
- . . . . . . . . . . . . . . . .
36
- . . . . . . . . . . . . . . . .
37
- . . . . . . . . . . . . . . . .
38
- . . . . . . . . . . . . . . . .
39
- . . . . . . . . . . . . . . . .
40
- . . . . . . . . . . . . . . . .
41
- . . . . . . . . . . . . . . . .
42
- `
43
- }
44
- tiles.setTilemap(tiles.createTilemap(
45
- hex`0a0008000000000000000000000009090909090909090909000000000000000000000000000000000000000000000000000000000000000000000000000000000909090909090909090900000000000000000000`,
46
- img`
47
- . . . . . . . . . .
48
- . . . . . . . . . .
49
- . . . . . . . . . .
50
- . . . . . . . . . .
51
- . . . . . . . . . .
52
- . . . . . . . . . .
53
- . . . . . . . . . .
54
- . . . . . . . . . .
55
- `,
56
- [myTiles.tile0,sprites.castle.tilePath4,sprites.castle.tilePath3,sprites.castle.tilePath1,sprites.castle.tilePath9,sprites.castle.tilePath6,sprites.castle.tilePath8,sprites.castle.tilePath7,sprites.castle.tilePath2,sprites.castle.tilePath5],
57
- TileScale.Sixteen
58
- ))
59
- for (let index = 0; index <= 9; index++) {
60
- tiles.setWallAt(tiles.getTileLocation(index, 1), true)
61
- tiles.setWallAt(tiles.getTileLocation(index, 6), true)
62
- }
21
+ let isWall = false
22
+ tiles.setTilemap(tilemap`level1`)
63
23
  let mySprite = sprites.create(img`
64
- 2 5 5 5 5 5 5 5 5 5 5 5 5 5 2 2
65
- 2 2 2 5 5 5 5 5 5 5 5 5 5 2 2 3
66
- 7 7 2 2 5 5 5 5 5 5 5 5 2 2 3 3
67
- 7 7 7 2 2 5 5 5 5 5 5 2 2 3 3 3
68
- 7 7 7 7 2 5 5 5 5 5 2 2 3 3 3 3
69
- 7 7 7 7 7 2 5 5 5 5 2 3 3 3 3 3
70
- 7 7 7 7 7 2 2 5 5 2 2 3 3 3 3 3
71
- 7 7 7 7 7 7 2 2 2 2 3 3 3 3 3 3
72
- 7 7 7 7 7 7 7 2 2 3 3 3 3 3 3 3
73
- 7 7 7 7 7 7 7 2 2 2 2 3 3 3 3 3
74
- 7 7 7 7 7 7 2 2 4 4 4 2 2 3 3 3
75
- 7 7 7 7 7 2 4 4 4 4 4 4 2 2 3 3
76
- 7 7 7 2 2 4 4 4 4 4 4 4 4 2 3 3
77
- 7 7 2 2 4 4 4 4 4 4 4 4 4 2 2 3
78
- 7 2 2 4 4 4 4 4 4 4 4 4 4 4 2 3
79
- 2 2 4 4 4 4 4 4 4 4 4 4 4 4 2 2
80
- `, SpriteKind.Player)
81
- mySprite.setVelocity(50, 50)
82
- mySprite.setFlag(SpriteFlag.BounceOnWall, true)
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
+ })
83
50
  ```
84
51
 
85
52
  ## See also #seealso
86
53
 
87
- [set tile](/reference/tiles/set-tile), [get tile location](/reference/tiles/get-tile-location)
54
+ [get tile location](/reference/tiles/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(tiles.getTileLocation(0, 0), null)
7
+ ```
8
+
9
+ ## Parameters
10
+
11
+ * **location**: a [location](/reference/scene/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/tiles/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
+ ```