+1

C# 2d Array map Help Please

Hi there. I'm working on the maze game which use 2d array as map. Game works just fine if the 2d array is predefined. var lines = File.ReadAllLines("../../array.txt"); int[,] maps = new int[lines.Length, 15]; for (int i = 0; i < lines.Length; ++i) { var data = lines[i].Split(',').Select(c => Convert.ToInt32(c)).ToList(); for (int j = 0; j < 15; ++j) maps[i, j] = data[j]; } This is the code which I use to read array and convert it to int but have no idea how to implement this in my game code. So far i can print array and it look as it should but whenever I try to use it for the game it is just filled with zeros. Any suggestions? Thank you

1/17/2018 5:08:47 PM

Wojtek Franczak

1 Answer

New Answer

0

when you give value to the lines variable it should be of type string right? so when you declare the maps array one of "maps" boundry is the Length property of lines (which includes the commas in the string file)