using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Sandbox.Map;
using Sandbox.Tiles;
namespace Sandbox
{
public class Game1 : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
Texture2D spriteFloor;
Texture2D spriteWall;
GameMap FirstMap = new GameMap(20, 11);
List
titles;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
protected override void Initialize()
{
FirstMap.setMap();
setGameMap();
base.Initialize();
}
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
spriteFloor = Content.Load("floor");
spriteWall = Content.Load("wall");
}
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
public void setGameMap()
{
titles = new List();
int X = 0;
int Y = 0;
for (int i = 0; i < FirstMap.width; i++)
{
for (int j = 0; j < FirstMap.length; j++)
{
if (FirstMap.map[i, j] == 1)
{
Title aWall = new Wall(spriteWall);
aWall.Position.X = X;
aWall.Position.Y = Y;
titles.Add(aWall);
}
else if (FirstMap.map[i, j] == 0)
{
Title aFloor = new Floor(spriteFloor);
aFloor.Position.X = X;
aFloor.Position.Y = Y;
titles.Add(aFloor);
}
X += 30;
}
X = 0;
Y += 30;
}
}
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
// TODO: Add your update logic here
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
foreach (Title element in titles)
{
element.draw(spriteBatch);
}
spriteBatch.End();
base.Draw(gameTime);
}
}
}