|
|
@ -85,8 +85,14 @@ namespace SemiColinGames { |
|
|
|
readonly Tile[] tiles; |
|
|
|
readonly Aabb[] collisionTargets; |
|
|
|
|
|
|
|
public int Width { get; private set; } |
|
|
|
public int Height { get; private set; } |
|
|
|
// Size of World in terms of tile grid.
|
|
|
|
private readonly int tileWidth; |
|
|
|
private readonly int tileHeight; |
|
|
|
|
|
|
|
// Size of World in pixels.
|
|
|
|
public int Width { |
|
|
|
get { return tileWidth * TileSize; } |
|
|
|
} |
|
|
|
|
|
|
|
readonly string worldString = @"
|
|
|
|
|
|
|
@ -109,11 +115,11 @@ namespace SemiColinGames { |
|
|
|
public World(Texture2D texture) { |
|
|
|
var tilesList = new List<Tile>(); |
|
|
|
string[] worldDesc = worldString.Split('\n'); |
|
|
|
Width = worldDesc.AsQueryable().Max(a => a.Length); |
|
|
|
Height = worldDesc.Length; |
|
|
|
Debug.WriteLine("world size: {0}x{1}", Width, Height); |
|
|
|
for (int i = 0; i < Width; i++) { |
|
|
|
for (int j = 0; j < Height; j++) { |
|
|
|
tileWidth = worldDesc.AsQueryable().Max(a => a.Length); |
|
|
|
tileHeight = worldDesc.Length; |
|
|
|
Debug.WriteLine("world size: {0}x{1}", tileWidth, tileHeight); |
|
|
|
for (int i = 0; i < tileWidth; i++) { |
|
|
|
for (int j = 0; j < tileHeight; j++) { |
|
|
|
Terrain terrain = Terrain.Empty; |
|
|
|
if (i < worldDesc[j].Length) { |
|
|
|
switch (worldDesc[j][i]) { |
|
|
@ -172,7 +178,7 @@ namespace SemiColinGames { |
|
|
|
|
|
|
|
// Add a final synthetic collisionTarget on the right side of the world.
|
|
|
|
collisionTargets[tiles.Length + 1] = new Aabb( |
|
|
|
new Vector2(Width * TileSize + 1, 0), new Vector2(1, float.MaxValue)); |
|
|
|
new Vector2(Width + 1, 0), new Vector2(1, float.MaxValue)); |
|
|
|
} |
|
|
|
|
|
|
|
public void Draw(SpriteBatch spriteBatch, Camera camera) { |
|
|
|