Following my code refactoring spree for Battle City, I'd like to improve loading and storing of levels. After some limited searching (I'm on vacation with limited access to the Internet) I couldn't find anything that I could use.
Currently, my levels look like this:
[Level1] S0W0000S0000W0S 000000ttt000000 0MGM000h000MGM0 0GGG00ygl00GGG0 0MGM00BBB00MGM0 000000BWB000000 GGGGGGGWGGGGGGG WWWWWWGGGWWWWWW GGGGGGGWGGGGGGG 000000BWB000000 0MGM00BBB00MGM0 0GGG00s0a00GGG0 0MGM0000000MGM0 000000fhd000000 00W001kCj200W00
Which is simple: read with double For loop char by char and create tile which that char represents.
There are few problems with it that I notice :
- Amount of characters I can use for that is limited. Tiles like brick wall require not 1 but about 13 - one character for each variation of the tile.
- Approach is ok for 15x15 tiles, but it may cause problems if I ever expand to a variable dimensions (with 15x15 being minimum). Not only the text file will become huge or at least wide, reading each level will become painfully slow with current system.
So, my questions are:
- Since I use XNA, is XML good enough for storing level data? I'd like to store tiles as either list of "type subtype position" or "type position_rectangle source_rectangle". I've been searching Internet a little and found a way to do a variation of that but for single level only, is there a simple way to do that for all levels in one file?
- This is probably too broad question and too low-level for C# - if I decide on writing a custom level data type, what are the general ideas behind it? I couldn't find anything or the Net (or my searching skills suck) and with my knowledge I only though of creating the binary file and write in it what I need or want.
Maybe I'm just thinking too hard.
Thanks in advance, even if the answer is just "search better"