Beispiel #1
0
 private void GenerateMap(heightMapGauss terrwain)
 {
     int[,] heightMap = terrwain.getHeightMap();
     Color[] colors = new Color[heightMap.Length];
     int heightMapMax = terrwain.findMaxHeight();
     int heightMapWidth = heightMap.GetUpperBound(0) + 1;
     int heightMapHeight = heightMap.GetUpperBound(1) + 1;
     terrain = new Texture2D(this.graphicsdevice, heightMapWidth, heightMapHeight, true, SurfaceFormat.Color);
     for (int i = 0; i < heightMapHeight; i++) // TODO currently, we have to manually change all of these 1025's when we increase the size of the map. UGH!
     {
         for (int j = 0; j < heightMapWidth; j++)
         {
             int cell = heightMap[i, j];
             if (cell > 0)
             {
                 colors[i * heightMapWidth + j] = new Color((255 * cell) / heightMapMax, 192 + (63 * (cell) / heightMapMax), (255 * cell) / heightMapMax);
             }
             else
             {
                 colors[i * heightMapWidth + j] = new Color(0, 0, 150);
             }
         }
     }
     terrain.SetData<Color>(colors);
     SetInStartPos();
 }
Beispiel #2
0
 public map(GraphicsDevice graphicsdevice, heightMapGauss terrwain, Rectangle border)
 {
     this.graphicsdevice = graphicsdevice;
     GenerateMap(terrwain);
     this.border = border;
 }