Browse Source

pull Width and Height into properties

GitOrigin-RevId: fe969e51cd
master
Colin McMillen 4 years ago
parent
commit
7e8e5c3e6d
  1. 17
      Shared/World.cs

17
Shared/World.cs

@ -82,12 +82,10 @@ namespace SemiColinGames {
class World {
public const int TileSize = 16;
readonly int width;
readonly int height;
readonly List<Tile> tiles = new List<Tile>();
public int Width { get; }
public int Height { get; }
public int Width { get; private set; }
public int Height { get; private set; }
readonly string worldString = @"
@ -109,11 +107,11 @@ namespace SemiColinGames {
public World(Texture2D texture) {
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 j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
Width = worldDesc.AsQueryable().Max(a => a.Length);
Height = worldDesc.Length;
Debug.WriteLine("world size: {0}x{1}", Width, Height);
for (int j = 0; j < Height; j++) {
for (int i = 0; i < Width; i++) {
Terrain terrain = Terrain.Empty;
if (i < worldDesc[j].Length) {
switch (worldDesc[j][i]) {
@ -141,7 +139,6 @@ namespace SemiColinGames {
case 'X':
terrain = Terrain.Block;
break;
case ' ':
default:
terrain = Terrain.Empty;
break;

Loading…
Cancel
Save