# Tilemap col/row to x/y conversion

**URL:** https://forum.makecode.com/t/tilemap-col-row-to-x-y-conversion/3176
**Category:** Help
**Created:** [August 20, 2020, 6:12pm UTC](https://forum.makecode.com/t/tilemap-col-row-to-x-y-conversion/3176 "2020-08-20T18:12:51Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![techahoynyc](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/techahoynyc/32/1023_2.png) [@techahoynyc](https://forum.makecode.com/u/techahoynyc)
#### Post date: [August 20, 2020, 6:12pm UTC](https://forum.makecode.com/t/tilemap-col-row-to-x-y-conversion/3176/1 "2020-08-20T18:12:51Z")

</div>

Is there a way to easily convert a tilemap col/row position to an x/y coorindates?

Some block refer to tilemap col/row positions and others refer to x/y coordinates. So far the only way I know to get the actual x/y coordinates is to turn on physics for my character, walk them over the tilemap in game, and read the co/row position physics is showing.

I need both the col/row and x/y values because I am trying to create an event that willcause the camera to refocus on a part of the map when my character crosses a certain area. The camera focus block uses x/y coordinates and the tilemap overlap blocks uses col/row positions.

---

<div class="post-metadata">

### Author: ![jacob\_c](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jacob_c/32/1532_2.png) [@jacob\_c](https://forum.makecode.com/u/jacob_c)
#### Post date: [August 20, 2020, 6:37pm UTC](https://forum.makecode.com/t/tilemap-col-row-to-x-y-conversion/3176/2 "2020-08-20T18:37:17Z")

</div>

Tilemap tiles are 16x16. If you have a tilemap position like `(0, 3)`, you can get x/y coordinates by multiplying by 16:

```auto
(0, 3) tilecoords * 16 = (0, 48) x/y coords

```

Keep in mind: this gives you the x/y coordinates of the **top** and **left** of the tile. If you want to get closer to the center (“center” is funny because with an even number, the center is between pixels), you’ll want to also add half the tile width/height (`8`).

```auto
(0, 3) * 16 = (0, 48)
              (0, 48) + 8 = (8, 56) // "center" of tile at (0, 3)

```

Does that help?

---

<div class="post-metadata">

### Author: ![techahoynyc](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/techahoynyc/32/1023_2.png) [@techahoynyc](https://forum.makecode.com/u/techahoynyc)
#### Post date: [August 20, 2020, 6:52pm UTC](https://forum.makecode.com/t/tilemap-col-row-to-x-y-conversion/3176/3 "2020-08-20T18:52:09Z")

</div>

Thanks @jacob_c - nice and clear explanation.

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [August 20, 2020, 7:29pm UTC](https://forum.makecode.com/t/tilemap-col-row-to-x-y-conversion/3176/4 "2020-08-20T19:29:31Z")

</div>

@techahoynyc you can also add the `microsoft/pxt-tilemaps` extension which includes some blocks for converting between coordinates. Just click the “+ Extension” button under advanced in the toolbox and paste `microsoft/pxt-tilemaps` into the search box.
