public void Draw(SpriteBatch spriteBatch, Player player, Area area) { Tile[,] map = area.GetTiles(); // draw level, outer loop is horizontal for (int i = 0; i < area.GetWidth(); ++i) { // inner loop is vertical for (int j = 0; j < area.GetHeight(); ++j) { map[i, j].Draw(spriteBatch, player.GetOffset()); } } player.Draw(spriteBatch); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); EntityManager.Initialize(); Vector2 playPos = new Vector2( (graphics.PreferredBackBufferWidth / 2) - 16, (graphics.PreferredBackBufferHeight / 2) -16 ); EntityManager.AddEntity(new Player(playPos, Vector2.Zero, Vector2.Zero, 2, AssetManager.GetTexture("temp"), new Rectangle(0, 0, 32, 32), Color.White, 100, 1)); area = new Area(25, 25); camera = new Camera(Vector2.Zero, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight); }