It seems like this has been asked lot, but I'm not sure any of the answers work for me. I'm fairly new to programming (I've been doing as a hobby of and on for quite a few years).
Here is my question;
I'm using a 2d array of integers and a list of source rectangles to create my tile map. I'm using the 2 for loops in the draw method to draw the tile map(if there is a better way to get the map drawn using a spritesheet I'm listening). The game is a top down style game, not a platformer.
What's the best way of detecting collision for certain tiles. I've thought about placing a new rectangle on the tiles that are impassable, but I'm not sure how to implement that. I would really like to use the intersects method, is there any using it with top, bottom, sides method? Is there a better way?
I'm happy to share all my code if that will help.
Thanks for the help.
So I have somewhat figured this out. I created a 2d int array collision map, basically 0's and 1's, ones are the passable tiles, but it really doesn't matter which numbers you use. I then run through the array and create a list of rectangles for the non passable tiles. I then check for collision using a foreach loop and checking the Rectangle.Intersects method with the player sprite rectangle (which I've made a smaller collision rectangle for it)
I may move the collision detection from the map class I created to the character class I created for more control over the player position.
I will post all the code for this later today.
Main game1 class
Character class
Map class