public void Draw(GameTime gameTime, SpriteBatch spriteBatch) { float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds; //Draw backgrounds Rectangle screenRectangle = new Rectangle(0, 0, _width * Tile.DefaultWidth, _height * Tile.DefaultHeight); BoundingBox screenBox = screenRectangle.MakeBoundingBox(); foreach (BackgroundTexture texture in _backgroundTextures) { Rectangle destination = new Rectangle(texture.Point.X * Tile.DefaultWidth - ScrollOffset, texture.Point.Y * Tile.DefaultHeight, texture.Width, texture.Height); BoundingBox destinationBoundingBox = destination.MakeBoundingBox(); if (destinationBoundingBox.Intersects(screenBox)) { //we can see it! spriteBatch.Draw(texture.Texture, destination, Color.White); } } //Draw tiles for (int i = 0; i < ViewWidth + 1; i++) { for (int j = 0; j < Height; j++) { if (i + ScrollOffset / Tile.DefaultWidth < 0) { continue; } Tile tile = _tiles[j, i + ScrollOffset / Tile.DefaultWidth]; if (tile == null) { continue; } if (!tile.IsAlive) { continue; } //Vector2 pos = new Vector2(Tile.DefaultWidth * i - (ScrollOffset % Tile.DefaultWidth), Tile.DefaultHeight * j); //Rectangle dest = new Rectangle((int)pos.X, (int)pos.Y, Tile.DefaultWidth, Tile.DefaultHeight); //spriteBatch.Draw(tile.Texture, dest, Color.White); tile.Draw(gameTime, spriteBatch); } } //Draw player ActivePlayer.Draw(gameTime, spriteBatch); //Draw Objects MapObjects.Draw(gameTime, spriteBatch); //Draw Particle Effects _particleEffects.Draw(gameTime, spriteBatch); }