Browse Source

Use world definition from Levels file

GitOrigin-RevId: a5d19f4f08
master
Colin McMillen 4 years ago
parent
commit
80746ecaed
  1. 4
      Shared/SneakGame.cs
  2. 22
      Shared/World.cs

4
Shared/SneakGame.cs

@ -67,13 +67,15 @@ namespace SemiColinGames {
font = Content.Load<SpriteFont>("font");
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");
grasslandBg2 = Content.Load<Texture2D>("grassland_bg2");
}
// Called once per game. Unloads all game content.
protected override void UnloadContent() {
updateTimer.DumpStats();
drawTimer.DumpStats();
}
// Updates the game world.

22
Shared/World.cs

@ -72,24 +72,6 @@ namespace SemiColinGames {
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 =
new Dictionary<char, Terrain>() {
{ '=', Terrain.Grass },
@ -102,9 +84,9 @@ namespace SemiColinGames {
{ 'X', Terrain.Block }
};
public World(Texture2D texture) {
public World(Texture2D texture, string levelSpecification) {
var tilesList = new List<Tile>();
string[] worldDesc = worldString.Split('\n');
string[] worldDesc = levelSpecification.Split('\n');
tileWidth = worldDesc.AsQueryable().Max(a => a.Length);
tileHeight = worldDesc.Length;
Debug.WriteLine("world size: {0}x{1}", tileWidth, tileHeight);

Loading…
Cancel
Save