예제 #1
0
        public static bool WormHasBeen(float seedI, float seedJ)
        {
            var   n = NoiseHelper.GustavsonNoise((seedI / Chunk.ChunkWidth) / 8, seedJ / Chunk.ChunkHeight, false, true);
            float n1;
            float add   = NoiseGenerator.GenFloatNoise(seedI + seedJ, 4);
            float ratio = Chunk.ChunkWidth / Chunk.ChunkHeight;

            n1 = NoiseHelper.GustavsonNoise(seedI / Chunk.ChunkWidth + add * ratio, seedJ / Chunk.ChunkHeight + add, false, true);
            n  = Player.Lerp(n + n1 * 1.5f, 0, (Chunk.ChunkHeight * 3) / (seedJ + 1));
            return(n >= 1.15f);
        }
예제 #2
0
        void GenerateMap()
        {
            blockNoise   = new float[mapWidth, mapHeight];
            clusterBlock = Block.BlockType.Dirt;

            GenerateHeights();

            blockMinValue = float.MaxValue;
            blockMaxValue = float.MinValue;

            for (int y = 0; y < mapHeight; y++)
            {
                for (int x = offsetUnitsX; x < mapWidth; x++)
                {
                    float xCoord = (float)x / mapWidth;
                    float yCoord = (float)y / mapWidth;

                    blockNoise[x, y] = 0;

                    if (heights[x] < (y * Cell.cellHeight))        // these coordinates will contain a block
                    {
                        for (int i = 1; i < blockOctaves + 1; i++) // implement octaves pleeeeeeaaaaaase
                        {
                            //float noise = 0;
                            //noise = Math.Abs(blockNoiseMap.GetPerlin((xCoord * blockFrequency * i) + offset.X, (yCoord * blockFrequency * i) + offset.Y)) * (blockLacunarity / i) * (float)Math.Pow(y, blockDepthRarity) * .0005f;
                        }
                        float noise = NoiseHelper.GustavsonNoise((xCoord * blockFrequency) + offset.X, (yCoord * blockFrequency) + offset.Y) * blockLacunarity * (y / 450f); //(float)Math.Pow(y, blockDepthRarity) * .001f;
                        blockNoise[x, y] = Math.Abs(noise);

                        //set heights
                        Block cellBlock = new Block(GenerateBlockType(x, y));
                        Block.PlaceBlock(Cell.grid[x, y], cellBlock);
                        world.map.Add(Cell.grid[x, y]);

                        if (blockNoise[x, y] < blockMinValue)
                        {
                            blockMinValue = blockNoise[x, y];
                        }
                        else if (blockNoise[x, y] > blockMaxValue)
                        {
                            blockMaxValue = blockNoise[x, y];
                        }
                    }
                }
            }
        }