- Home /
Storing Level Data in Array of Array (grid-based game)
Hi, I'm currently making a grid-based puzzle game (8x8) and I would like to store the level data. I know I could use files to store the "level data" but couldn't I simply use arrays (an array of arrays) to store the data?
Like (simplified (3x3)):
Level1
101
110
010
Level2
001
010
011
...
Pseudocode:
LevelData[] = [
[
[1,0,1],
[1,1,0],
[0,1,0]],
[
[0,0,1],
[0,1,0],
[0,1,1]]
It's de facto an arrray of multidimensional arrays. I would than read the data like
CurrentLevel[,] = LevelData[0];
Is it even possible? Have been googling w/o success. If it is impossible, I will use a badly readable version like string[] LevelData = {"101110010","001010011"..} and do some converting and calculations or the file-based version. But I'd prefer the other version if possible.
Best regards
Answer by TheyLeftMe4Dead · Jan 16, 2017 at 07:53 AM
I don't know what you mean by storing your level information into a matrix. If you store your level info into a matrix at runtime, the matrix will be defined--but only while your game is running. You have to store the data externally (from what I understand) in order to use it again somewhere else. This process of storing/retrieving/transferring data through (text) files is called streaming. This link might help:
http://www.introprogramming.info/english-intro-csharp-book/read-online/chapter-15-text-files/
Your answer
Follow this Question
Related Questions
How to display data from array,arraylist while clicking the button? 1 Answer
Hashtable and ArrayList problem 0 Answers
AudioSource Array Index is out of range 3 Answers
Collections don't work! 1 Answer
Unity C# Highscore table 2 Answers