Saving an array of types
BlitzMax Forums/BlitzMax Beginners Area/Saving an array of types
| ||
I want to store the tiled map in my game as multi-dimensional array of types. I want to save it as a file on my harddisk. What is the best way of doing this? for example global map:tile[100,100] type tile field data1:int field data2:int field data3:int .... endtype thank you |
| ||
Local stream:TStream = WriteStream("yourfile.txt") Local i:Int Local j:Int For i = 0 Until 100 For j = 0 Until 100 WriteInt( stream, map[i,j].data1 ) WriteInt( stream, map[i,j].data2 ) WriteInt( stream, map[i,j].data3 ) Next Next CloseStream( stream ) Not tested but should work. EDIT: ----------------- For restoring your type, you would run the above loop again but instead use the ReadInt command to get the data. Look in BMax Help -> Modules -> Streams -> BRL.Stream Last edited 2011 Last edited 2011 |
| ||
thanks very much Shinkiro :D |