예제 #1
0
        public static void Generate(Mine2D game, TextureAtlas textureAtlas, World world, int seed)
        {
            LibNoise.Perlin noise = new LibNoise.Perlin();
            noise.Seed = seed;

            List<int> maxTreesY = new List<int>();
            for (int x = -256; x < 256; x++)
            {
                double Y = noise.GetValue((float)x / 17F, 1, 1) * 4;
                int y = (int)Y;
                maxTreesY.Add(16 - y - 16);
                Blocks.Grass grass = new Blocks.Grass(textureAtlas);
                world.SetBlock(new Vector2(x, 16 - y), grass);

                int dirtY = new Random(seed + x + y).Next(2, 5);
                int stoneY = y - new Random(seed + x + y + 1).Next(5, 8) + (3 - dirtY);
                for (int i = y - dirtY; i < y; i++)
                {
                    Blocks.Dirt dirt_ = new Blocks.Dirt(textureAtlas);
                    world.SetBlock(new Vector2(x, 16 - i), dirt_);
                }
                for (int i = -24; i < 4 + y + (4 - dirtY) + 1; i++)
                {
                    Blocks.Stone stone_ = new Blocks.Stone(textureAtlas);
                    world.SetBlock(new Vector2(x, 16 - i + 9), stone_);
                }
                for (int i = y + stoneY - 7; i < 4 + y + stoneY + 1; i++)
                {
                    Blocks.Cobblestone cobblestone_ = new Blocks.Cobblestone(textureAtlas);
                    world.SetBlockWithReplace(new Vector2(x, 16 - i + 10), cobblestone_);
                }
                GenerateOres(world, textureAtlas, x, y, stoneY, seed);

                Blocks.Bedrock bedrock_ = new Blocks.Bedrock(textureAtlas);
                world.SetBlock(new Vector2(x, 50), bedrock_);
            }
            GenerateTrees(-256, 256, maxTreesY.ToArray(), seed, world, textureAtlas);

            game.gameState = GameState.Playing;
        }
 public static float noise(LibNoise.Perlin heightNoise, float x, float y, float z, float s)
 {
     return((float)heightNoise.GetValue(x * s, y * s, z * s));
 }