public void Draw(SpriteBatch spriteBatch, Texture2D sprite, Bounds bounds) { int x = DestRect.X; int y = DestRect.Y; if (x > bounds.MinX && x < bounds.MaxX && y > bounds.MinY && y < bounds.MaxY) spriteBatch.Draw(sprite, DestRect, SourceRect, Colour); }
public void Draw(SpriteBatch spriteBatch) { // Bounds, restricts the drawing of tiles int drawDistance = 512; CurrentBounds = new Bounds((int)playerCamera.Position.X - drawDistance, (int)playerCamera.Position.X + drawDistance, (int)playerCamera.Position.Y - drawDistance, (int)playerCamera.Position.Y + drawDistance); // Draw all the tiles foreach (Tile item in tiles) item.Draw(spriteBatch, CurrentTileSet, CurrentBounds); player.Draw(spriteBatch); }
public Level() { playerCamera = new Camera(new Vector2(512, 300)); CurrentBounds = new Bounds(0, 1024, 0, 600); }