transcribe 1-1 as testing World

GitOrigin-RevId: 0267ea2f77636413d5681b212a23177de47c91dd
This commit is contained in:
Colin McMillen 2019-12-17 17:21:14 -05:00
parent 81b62f883e
commit d3283a64c0

View File

@ -10,7 +10,10 @@ namespace Jumpy {
GrassL, GrassL,
GrassR, GrassR,
Rock, Rock,
Water RockL,
RockR,
Water,
Block
} }
class Tile { class Tile {
@ -38,25 +41,40 @@ namespace Jumpy {
break; break;
} }
case Terrain.GrassL: { case Terrain.GrassL: {
Rectangle source = new Rectangle(2 * size, 0 * size, size, size); Rectangle source = new Rectangle(2 * size, 0 * size, size, size);
spriteBatch.Draw(texture, drawPos, source, Color.White); spriteBatch.Draw(texture, drawPos, source, Color.White);
break; break;
} }
case Terrain.GrassR: { case Terrain.GrassR: {
Rectangle source = new Rectangle(4 * size, 0 * size, size, size); Rectangle source = new Rectangle(4 * size, 0 * size, size, size);
spriteBatch.Draw(texture, drawPos, source, Color.White); spriteBatch.Draw(texture, drawPos, source, Color.White);
break; break;
} }
case Terrain.Rock: { case Terrain.Rock: {
Rectangle source = new Rectangle(3 * size, 1 * size, size, size); Rectangle source = new Rectangle(3 * size, 1 * size, size, size);
spriteBatch.Draw(texture, drawPos, source, Color.White); spriteBatch.Draw(texture, drawPos, source, Color.White);
break; break;
} }
case Terrain.RockL: {
Rectangle source = new Rectangle(1 * size, 2 * size, size, size);
spriteBatch.Draw(texture, drawPos, source, Color.White);
break;
}
case Terrain.RockR: {
Rectangle source = new Rectangle(5 * size, 2 * size, size, size);
spriteBatch.Draw(texture, drawPos, source, Color.White);
break;
}
case Terrain.Water: { case Terrain.Water: {
Rectangle source = new Rectangle(9 * size, 2 * size, size, size); Rectangle source = new Rectangle(9 * size, 2 * size, size, size);
spriteBatch.Draw(texture, drawPos, source, Color.White); spriteBatch.Draw(texture, drawPos, source, Color.White);
break; break;
} }
case Terrain.Block: {
Rectangle source = new Rectangle(6 * size, 3 * size, size, size);
spriteBatch.Draw(texture, drawPos, source, Color.White);
break;
}
case Terrain.Empty: case Terrain.Empty:
default: default:
break; break;
@ -75,18 +93,18 @@ namespace Jumpy {
public int Height { get; } public int Height { get; }
string[] worldDesc = new string[] { string[] worldDesc = new string[] {
" .", " 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 ",
"=============> <==================================================================.", "===========================..========..======..=========..=========> <=============> <==============================================================> <=======..==============..==============================",
"..............~~~~~................................................................." }; "...................................................................] [.............] [..............................................................] [......................................................." };
public World(Texture2D texture) { public World(Texture2D texture) {
// TODO: better error handling for if the string[] isn't rectangular. // TODO: better error handling for if the string[] isn't rectangular.
@ -109,9 +127,18 @@ namespace Jumpy {
case '.': case '.':
terrain = Terrain.Rock; terrain = Terrain.Rock;
break; break;
case '[':
terrain = Terrain.RockL;
break;
case ']':
terrain = Terrain.RockR;
break;
case '~': case '~':
terrain = Terrain.Water; terrain = Terrain.Water;
break; break;
case 'X':
terrain = Terrain.Block;
break;
case ' ': case ' ':
default: default:
terrain = Terrain.Empty; terrain = Terrain.Empty;