# c# – Confused about Clint Bellinger’s article about converting coordinates to isometric tiles

I am trying to follow an article by Clint Bellinger with regards to converting coordinates to tile coordinates.

The theory behind it all makes perfect sense but for some reason, when I attempt to put his code into practice, I must be doing something wrong OR I am misinterpreting it and it appears I am getting the wrong tile coordinates.

Fiddle

``````using System;

public class Program
{
public void Main()
{
coordsToTile(0, 0);
coordsToTile(0, 32);
coordsToTile(32, 0);
coordsToTile(32, 32);
}

public void coordsToTile(int x, int y){
int Height = 32;
int Width = 64;

int tileX = (x / (Width / 2) + y / (Height / 2)) /2;
int tileY = (y / (Height / 2) -(x / (Width / 2))) /2;

Console.WriteLine("X: " + tileX + " Y: " + tileY);

}
}
``````

I then get this output

``````X: 0 Y: 0
X: 1 Y: 1
X: 0 Y: 0
X: 1 Y: 0
``````

I was expecting something like below

``````X: 0 Y: 0
X: 0 Y: 1
X: 1 Y: 0
X: 1 Y: 1
``````

Either I’m doing something wrong or the article isn’t suited for what I’m trying but I’ve been stuck on this for days and cannot work out why.

Posted on Categories Articles