title: Screen to staggered isometric grid algorithm
body: <p>I'm working with Kivy and Pytmx, I need to get Grid Tile from Map Coordinates for staggered map.</p>
  <p><a href="https://i.stack.imgur.com/HjWQi.png" rel="nofollow noreferrer">mymap</a></p>
  <p>My tile size is:</p>
  <pre><code>TILE_WIDTH = 256
  TILE_HEIGHT = 149
  </code></pre>
  <p>When I used the isometric diamond grid, I calculated it like this:</p>
  <pre><code>def screen_to_isometric_grid(cartX, cartY):
      screenx = mh - cartY / (TILE_HEIGHT * SPRITE_SCALING) + cartX / (TILE_WIDTH * SPRITE_SCALING) - mw / 2 - 1 / 2
      screeny = mh - cartY / (TILE_HEIGHT * SPRITE_SCALING) - cartX / (TILE_WIDTH * SPRITE_SCALING) + mw / 2 - 1 / 2
      screenx2 = round(screenx)
      screeny2 = round(screeny)
      return screenx2, screeny2
  </code></pre>
  <p>Now I'm using staggered map and I dont know how to get tile coordinates.</p>
  <p>I found algorithm in C++ here <a href="https://coderoad.ru/35885029/%D0%9F%D0%BE%D0%B2%D1%8B%D1%88%D0%B5%D0%BD%D0%B8%D0%B5-%D0%BF%D1%80%D0%BE%D0%B8%D0%B7%D0%B2%D0%BE%D0%B4%D0%B8%D1%82%D0%B5%D0%BB%D1%8C%D0%BD%D0%BE%D1%81%D1%82%D0%B8-%D0%BE%D0%B1%D0%BD%D0%B0%D1%80%D1%83%D0%B6%D0%B5%D0%BD%D0%B8%D1%8F-%D1%89%D0%B5%D0%BB%D1%87%D0%BA%D0%BE%D0%B2-%D0%BD%D0%B0-%D0%B8%D0%B7%D0%BE%D0%BC%D0%B5%D1%82%D1%80%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%BE%D0%B9-%D1%81%D0%B5%D1%82%D0%BA%D0%B5-%D1%81" rel="nofollow noreferrer">enter link description here</a></p>