So, Im making a game in c# using Xna. I have a function that will read a text file and display a map on screen, using numbers in the file as texture references. The file is a integer multidimensional array. I have another file which is used to set collision bounds, called collisionMap.txt.

My thinking was this:

  1. Read collision map file
  2. If any value within the array equaly '1', then that tile will be inpassable.
  3. Get x and y positions of that wile within the array.
  4. These inpassable tiles will be added to another array containing only array positions of inpassable tiles.
  5. Calculate screen positions of the inpassable tiles. I will do this by timising the x and y array position by the tile width and height.
  6. Proceeed with noral collision detection.

My question is, how can I check collisionMap.txt for any values equal to '1' and get the array position?

Any and all comments will be appreciated!

3 Years
Discussion Span
Last Post by CJMW

Hi, I think to read some text file you may use FileStream concept and then you may parse that text file in order to search a particular value.


Hey! Thanks for the reply! I actually managed to work this problem out on my own last night. I was reading the wrong part of the array. I also created a Rectangle[], but failed to make it multidimensial. Oh well, got it working now :D

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.