pull Width and Height into properties
GitOrigin-RevId: fe969e51cd393ff350f57acc38cc416954d57252
This commit is contained in:
parent
16062f65c3
commit
7e8e5c3e6d
@ -82,12 +82,10 @@ namespace SemiColinGames {
|
|||||||
class World {
|
class World {
|
||||||
|
|
||||||
public const int TileSize = 16;
|
public const int TileSize = 16;
|
||||||
readonly int width;
|
|
||||||
readonly int height;
|
|
||||||
readonly List<Tile> tiles = new List<Tile>();
|
readonly List<Tile> tiles = new List<Tile>();
|
||||||
|
|
||||||
public int Width { get; }
|
public int Width { get; private set; }
|
||||||
public int Height { get; }
|
public int Height { get; private set; }
|
||||||
|
|
||||||
readonly string worldString = @"
|
readonly string worldString = @"
|
||||||
|
|
||||||
@ -109,11 +107,11 @@ namespace SemiColinGames {
|
|||||||
|
|
||||||
public World(Texture2D texture) {
|
public World(Texture2D texture) {
|
||||||
string[] worldDesc = worldString.Split('\n');
|
string[] worldDesc = worldString.Split('\n');
|
||||||
width = worldDesc.AsQueryable().Max(a => a.Length);
|
Width = worldDesc.AsQueryable().Max(a => a.Length);
|
||||||
height = worldDesc.Length;
|
Height = worldDesc.Length;
|
||||||
Debug.WriteLine("world size: {0}x{1}", width, height);
|
Debug.WriteLine("world size: {0}x{1}", Width, Height);
|
||||||
for (int j = 0; j < height; j++) {
|
for (int j = 0; j < Height; j++) {
|
||||||
for (int i = 0; i < width; i++) {
|
for (int i = 0; i < Width; i++) {
|
||||||
Terrain terrain = Terrain.Empty;
|
Terrain terrain = Terrain.Empty;
|
||||||
if (i < worldDesc[j].Length) {
|
if (i < worldDesc[j].Length) {
|
||||||
switch (worldDesc[j][i]) {
|
switch (worldDesc[j][i]) {
|
||||||
@ -141,7 +139,6 @@ namespace SemiColinGames {
|
|||||||
case 'X':
|
case 'X':
|
||||||
terrain = Terrain.Block;
|
terrain = Terrain.Block;
|
||||||
break;
|
break;
|
||||||
case ' ':
|
|
||||||
default:
|
default:
|
||||||
terrain = Terrain.Empty;
|
terrain = Terrain.Empty;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user