diff --git a/Shared/World.cs b/Shared/World.cs index 159188a..05fbb2b 100644 --- a/Shared/World.cs +++ b/Shared/World.cs @@ -102,6 +102,8 @@ namespace SemiColinGames { public World(string json) { JObject root = JObject.Parse(json); + List decorationTiles = new List(); + List backgroundTiles = new List(); foreach (JToken layer in root.SelectToken("layers").Children()) { string layerName = layer.SelectToken("name").Value(); if (layerName == "entities") { @@ -110,13 +112,18 @@ namespace SemiColinGames { continue; } List tileList = ParseLayer(layer); - // TODO: add background layer if (layerName == "obstacles") { tiles = tileList.ToArray(); } else if (layerName == "decorations") { - decorations = tileList.ToArray(); + decorationTiles = tileList; + } else if (layerName == "background") { + backgroundTiles = tileList; } } + // The background tiles are added before the rest of the decorations, so that they're drawn + // in the back. + backgroundTiles.AddRange(decorationTiles); + decorations = backgroundTiles.ToArray(); Debug.WriteLine("world size: {0}x{1}", gridWidth, gridHeight); // Because we added tiles from left to right, the CollisionTargets are sorted by x-position.