fix how the first line of World is parsed

GitOrigin-RevId: 9409e491fd04067af750333b693d0f992bf6315d
This commit is contained in:
Colin McMillen 2020-02-20 13:36:59 -05:00
parent c4e211e750
commit 0ee671c8b1
2 changed files with 11 additions and 8 deletions

View File

@ -5,14 +5,15 @@
}; };
public const string DEMO = @" public const string DEMO = @"
7 <=============> 8 <=============>
6 { { { } { ; 7 { { { } { ;
5 } ; ; ; } 6 } ; ; ; }
4 } ; } 5 } ; }
3 } 4 }
3
2 2
1 1
0 <=X=X=X=> <=============> (__________) 0 <=X=X=X=> <===> <===> (__________)
5 / \ 5 / \
4 | | 4 | |
3 | | 3 | |
@ -33,6 +34,7 @@ w wr wqw t wew ww dfffxfffxfffb v twq r wtwv
......................................... .........................................
......................................... .........................................
......................................... .........................................
.........................................
0 [................................. 0 [.................................
1 [................................. 1 [.................................
2 [................................. 2 [.................................
@ -47,6 +49,7 @@ w wr wqw t wew ww dfffxfffxfffb v twq r wtwv
X X
. .
X <======> <==X X <=> <XX> XX . X <======> <==X X <=> <XX> XX .

View File

@ -15,7 +15,7 @@ namespace SemiColinGames {
} }
} }
private static Dictionary<char, Terrain> mapping = new Dictionary<char, Terrain>(); private readonly static Dictionary<char, Terrain> mapping = new Dictionary<char, Terrain>();
public static Terrain Grass = new Terrain('=', true); public static Terrain Grass = new Terrain('=', true);
public static Terrain GrassL = new Terrain('<', true); public static Terrain GrassL = new Terrain('<', true);
@ -160,7 +160,7 @@ namespace SemiColinGames {
TileFactory factory = new TileFactory(); TileFactory factory = new TileFactory();
var tilesList = new List<Tile>(); var tilesList = new List<Tile>();
var decorationsList = new List<Tile>(); var decorationsList = new List<Tile>();
string[] worldDesc = levelSpecification.Split('\n'); string[] worldDesc = levelSpecification.Substring(1).Split('\n');
tileWidth = worldDesc.AsQueryable().Max(a => a.Length); tileWidth = worldDesc.AsQueryable().Max(a => a.Length);
tileHeight = worldDesc.Length; tileHeight = worldDesc.Length;
Debug.WriteLine("world size: {0}x{1}", tileWidth, tileHeight); Debug.WriteLine("world size: {0}x{1}", tileWidth, tileHeight);