function startDisplacement(map,mapSize){
        var tr, tl, t, br, bl, b, r, l, center;

        // top left
        map[0][0] = Math.random(1.0);
        tl = map[0][0];

        // bottom left
        map[0][mapSize] = Math.random(1.0);
        bl = map[0][mapSize];

        // top right
        map[mapSize][0] = Math.random(1.0);
        tr = map[mapSize][0];

        // bottom right
        map[mapSize][mapSize] = Math.random(1.0);
        br = map[mapSize][mapSize];

        // Center
        map[mapSize/2][mapSize/2] = map[0][0] + map[0][mapSize] + map[mapSize][0] + map[mapSize][mapSize] / 4;
        map[mapSize/2][mapSize/2] = normalize(map[mapSize/2][mapSize/2]);
        center = map[mapSize/2][mapSize/2];

        /* Non wrapping terrain */
        map[mapSize/2][mapSize] = bl + br + center / 3;
        map[mapSize/2][0] = tl + tr + center / 3;
        map[mapSize][mapSize/2] = tr + br + center / 3;
        map[0][mapSize/2] = tl + bl + center / 3;

        // Call displacment
        midpointDisplacment(mapSize);
    }
// Starts off the map generation, seeds the first 4 corners
Starts off the map generation, seeds the first 4 corners
Starts off the map generation seeds the first 4 corners
function startDisplacement(map,mapSize){
        var tr, tl, t, br, bl, b, r, l, center;
        map[0][0] = Math.random(1.0);
        tl = map[0][0];
        map[0][mapSize] = Math.random(1.0);
        bl = map[0][mapSize];
        map[mapSize][0] = Math.random(1.0);
        tr = map[mapSize][0];
        map[mapSize][mapSize] = Math.random(1.0);
        br = map[mapSize][mapSize];
        map[mapSize/2][mapSize/2] = map[0][0] + map[0][mapSize] + map[mapSize][0] + map[mapSize][mapSize] / 4;
        map[mapSize/2][mapSize/2] = normalize(map[mapSize/2][mapSize/2]);
        center = map[mapSize/2][mapSize/2];
        map[mapSize/2][mapSize] = bl + br + center / 3;
        map[mapSize/2][0] = tl + tr + center / 3;
        map[mapSize][mapSize/2] = tr + br + center / 3;
        map[0][mapSize/2] = tl + bl + center / 3;
        midpointDisplacment(mapSize);
    }
function startDisplacement ( map , mapSize ) { var tr , tl , t , br , bl , b , r , l , center ; map [ 0 ] [ 0 ] = Math . random ( 1.0 ) ; tl = map [ 0 ] [ 0 ] ; map [ 0 ] [ mapSize ] = Math . random ( 1.0 ) ; bl = map [ 0 ] [ mapSize ] ; map [ mapSize ] [ 0 ] = Math . random ( 1.0 ) ; tr = map [ mapSize ] [ 0 ] ; map [ mapSize ] [ mapSize ] = Math . random ( 1.0 ) ; br = map [ mapSize ] [ mapSize ] ; map [ mapSize / 2 ] [ mapSize / 2 ] = map [ 0 ] [ 0 ] + map [ 0 ] [ mapSize ] + map [ mapSize ] [ 0 ] + map [ mapSize ] [ mapSize ] / 4 ; map [ mapSize / 2 ] [ mapSize / 2 ] = normalize ( map [ mapSize / 2 ] [ mapSize / 2 ] ) ; center = map [ mapSize / 2 ] [ mapSize / 2 ] ; map [ mapSize / 2 ] [ mapSize ] = bl + br + center / 3 ; map [ mapSize / 2 ] [ 0 ] = tl + tr + center / 3 ; map [ mapSize ] [ mapSize / 2 ] = tr + br + center / 3 ; map [ 0 ] [ mapSize / 2 ] = tl + bl + center / 3 ; midpointDisplacment ( mapSize ) ; }
Starts off the map generation, seeds the first 4 corners
Starts off the map generation seeds the first 4 corners
// top left // bottom left // top right // bottom right // Center /* Non wrapping terrain */ // Call displacment