Use world definition from Levels file
GitOrigin-RevId: a5d19f4f0828bb52989b12590d6e364d0edd918b
This commit is contained in:
parent
d30be7a460
commit
80746ecaed
@ -67,13 +67,15 @@ namespace SemiColinGames {
|
|||||||
font = Content.Load<SpriteFont>("font");
|
font = Content.Load<SpriteFont>("font");
|
||||||
|
|
||||||
player = new Player(Content.Load<Texture2D>("Ninja_Female"));
|
player = new Player(Content.Load<Texture2D>("Ninja_Female"));
|
||||||
world = new World(Content.Load<Texture2D>("grassland"));
|
world = new World(Content.Load<Texture2D>("grassland"), Levels.DEMO);
|
||||||
grasslandBg1 = Content.Load<Texture2D>("grassland_bg1");
|
grasslandBg1 = Content.Load<Texture2D>("grassland_bg1");
|
||||||
grasslandBg2 = Content.Load<Texture2D>("grassland_bg2");
|
grasslandBg2 = Content.Load<Texture2D>("grassland_bg2");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called once per game. Unloads all game content.
|
// Called once per game. Unloads all game content.
|
||||||
protected override void UnloadContent() {
|
protected override void UnloadContent() {
|
||||||
|
updateTimer.DumpStats();
|
||||||
|
drawTimer.DumpStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updates the game world.
|
// Updates the game world.
|
||||||
|
@ -72,24 +72,6 @@ namespace SemiColinGames {
|
|||||||
get { return tileHeight * TileSize; }
|
get { return tileHeight * TileSize; }
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly string worldString = @"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
X
|
|
||||||
.
|
|
||||||
X <======> <==X X <=> <XX> XX .
|
|
||||||
XXX .
|
|
||||||
XXXX .
|
|
||||||
XXXXX .
|
|
||||||
X <X=X> <> <> <X> = <> X X X X <> X X XX X <=X> XXXXXX .
|
|
||||||
<> [] [] XX XX XXX XX XXXXXXX
|
|
||||||
<> [] [] [] XXX XXX XXXX XXX <> <> XXXXXXXX
|
|
||||||
[]12345678[]123456[]123456789[]1234567890 123456 123456 12345 1234 12345 1234 123XXXX XXXX1234XXXXX XXXX1234[]123 1234567[]XXXXXXXXX12345678
|
|
||||||
====================> <====..========..======..=========..=========> <=============> <==============================================================> <=======..==============..==============================
|
|
||||||
....................] [............................................] [.............] [..............................................................] [.......................................................";
|
|
||||||
|
|
||||||
private static readonly Dictionary<char, Terrain> charToTerrain =
|
private static readonly Dictionary<char, Terrain> charToTerrain =
|
||||||
new Dictionary<char, Terrain>() {
|
new Dictionary<char, Terrain>() {
|
||||||
{ '=', Terrain.Grass },
|
{ '=', Terrain.Grass },
|
||||||
@ -102,9 +84,9 @@ namespace SemiColinGames {
|
|||||||
{ 'X', Terrain.Block }
|
{ 'X', Terrain.Block }
|
||||||
};
|
};
|
||||||
|
|
||||||
public World(Texture2D texture) {
|
public World(Texture2D texture, string levelSpecification) {
|
||||||
var tilesList = new List<Tile>();
|
var tilesList = new List<Tile>();
|
||||||
string[] worldDesc = worldString.Split('\n');
|
string[] worldDesc = levelSpecification.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);
|
||||||
|
Loading…
Reference in New Issue
Block a user