# Xna tile map collision

I finally found a tutorial on tile maps and loading them in from a file that I understand (http://circlessuck.blogspot.co.uk/2012/09/xna-tutorial-basic-tile-engine-part-2.html), however the tutorial doesn't show teach you how to do collision. I have vague idea in mind of what I might have to do from other tile map collisions I've seen, but I can't get it into code that will fit this style of loading tile maps. My tile map loadin:

private List<Texture2D> tiles;
private int[,] tileMap;

private const int tileWidth = 32;
private const int tileHeight = 32;

public TileMap(string name, ContentManager Content)
{
}

public void Draw(SpriteBatch spriteBatch)
{
for (int y = 0; y < tileMap.GetLength(0); y++)
{
for (int x = 0; x < tileMap.GetLength(1); x++)
{
spriteBatch.Draw(
tiles[tileMap[y, x]], new Vector2(x * tileWidth, y * tileHeight),
Color.White);
}
}
}

{
tiles = new List<Texture2D>();
}

{
string path = "Maps/" + name + ".txt";

int width = 0;

string[] tileNo = line.Split(',');

width = tileNo.Count();
tileMap = new int[height, width];

for (int y = 0; y < height; y++)
{
tileNo = line.Split(',');

for (int x = 0; x < width; x++)
{
tileMap[y, x] = Convert.ToInt32(tileNo[x]);
}
}

}


(I have a player class with basic physics that all work fine)

• There's no question here. If you're more specific in what you want, you're more likely to get an answer that suits you. – MichaelHouse Aug 18 '13 at 14:04
• tonypa.pri.ee/tbw/tut05.html - Great tutorial on tile-map collision. Its flash but the code is easily made workable in C# – dan369 Aug 18 '13 at 14:06
• Mark tiles that should collide with a flag/bool. Check tiles in vicinity of player if there respective triangles intersect. – Madmenyo Aug 23 '13 at 12:59
• Check out this link, I suspect it will be helpful : gamedev.stackexchange.com/questions/84208/… – Shroeder Oct 2 '14 at 16:34