# Tilemap Location of mysprite equation

**URL:** <https://forum.makecode.com/t/tilemap-location-of-mysprite-equation/39027>\
**Category:** Help\
**Created:** [September 2, 2025, 4:41pm UTC](https://forum.makecode.com/t/tilemap-location-of-mysprite-equation/39027 "2025-09-02T16:41:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![CoolCoder1](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/coolcoder1/32/23882_2.png) [@CoolCoder1](https://forum.makecode.com/u/CoolCoder1)\
**Post date:** [September 2, 2025, 4:41pm UTC](https://forum.makecode.com/t/tilemap-location-of-mysprite-equation/39027/1 "2025-09-02T16:41:08Z")

</div>

I’m in a tight spot in a makecode project, and I wont go over all the details right here in the topic summary, but I basically need to know the math to convert pixel coordinates to tile coordinates. like the tilemap location of mysprite block uses. I tried this equation thinking it would basically be the same: (truncate ((Amount - 8) / 16)) but it isnt close to the same thing, please if one of the makecode devs are reading this, could you please tell me what the equation is for this block? I’m definitely not a math expert!

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [September 2, 2025, 5:34pm UTC](https://forum.makecode.com/t/tilemap-location-of-mysprite-equation/39027/2 "2025-09-02T17:34:37Z")

</div>

The exact code we use is right here: [pxt-common-packages/libs/game/sprite.ts at 834a7016536dc2c8ac314e85e4e91c24654e6dd9 · microsoft/pxt-common-packages](https://github.com/microsoft/pxt-common-packages/blob/834a7016536dc2c8ac314e85e4e91c24654e6dd9/libs/game/sprite.ts#L895) – `tiles.getTileLocation` is just the ‘tilemap col row ’ block. x/y are the center of the sprite if that impacts what you’re using it for, and the important bit - the `>> scene.tileMap.scale` expresses the same as dividing by the tile size ignoring the remainder – like what you have if you remove the -8, assuming you are using 16x16 tiles.
