public void LoadMap(int width, int height, float scale = 0.1f) { this.scale = scale; w = width; h = height; Tiles = new Cell[width * height]; Simplex.Noise.Seed = 1; var noise = Simplex.Noise.Calc2D(width, height, scale); var minNoise = noise.Min(); var maxNoise = noise.Max(); noise.Map(n => n.Map(minNoise, maxNoise, min, max)); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { int cellIndex = y * width + x; Tiles[cellIndex] = new Cell(colorRamp[(int)noise[x, y]], Color.Black); if (isShowAll || ((int)noise[x, y] >= layerRangeMin && (int)noise[x, y] <= (layerRangeMin + layerRange))) { Tiles[cellIndex].Glyph = 178; } } } // Create a surface for drawing. It uses the tiles from a map object. surface = new BasicSurface(width, height, Tiles, SadConsole.Global.FontDefault, new Rectangle(0, 0, Width, Height)); drawCall = new SadConsole.DrawCallSurface(surface, position, false); }
public void LoadMap(Map map) { // Create a surface for drawing. It uses the tiles from a map object. surface = new BasicSurface(map.Width, map.Height, map.Tiles, SadConsole.Global.FontDefault, new Rectangle(0, 0, Width, Height)); drawCall = new SadConsole.DrawCallSurface(surface, position, false); }