Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Generate()
- {
- Random rnd = new Random();
- int lastHeight = rnd.Next(1, _height);
- for (int k = 0; k < _depth; k++)
- {
- int currentHeight = lastHeight + rnd.Next(-1, 2);
- currentHeight = Math.Min(_height, Math.Max(1, currentHeight));
- for (int j = 0; j < currentHeight; j++)
- {
- cubes[0, j, k] = new BlockGrass(new Vector3(0, 10 * j, 10 * k));
- }
- lastHeight = currentHeight;
- }
- lastHeight = GetHeight(0, 0);
- for (int i = 1; i < _width; i++)
- {
- int currentHeight = lastHeight + rnd.Next(-1, 2);
- currentHeight = Math.Min(_height, Math.Max(1, currentHeight));
- for (int j = 0; j < currentHeight; j++)
- {
- cubes[i, j, 0] = new BlockGrass(new Vector3(10 * i, 10 * j, 0));
- }
- lastHeight = currentHeight;
- }
- for (int i = 1; i < _width; i++)
- {
- for (int k = 1; k < _depth; k++)
- {
- int currentHeight = (GetHeight(i - 1, k) + GetHeight(i, k - 1)) / 2 + rnd.Next(-1, 2);
- currentHeight = Math.Min(_height, Math.Max(1, currentHeight));
- for (int j = 0; j < currentHeight; j++)
- {
- if (j < currentHeight - 1)
- {
- cubes[i, j, k] = new BlockGround(new Vector3(10 * i, 10 * j, 10 * k));
- }
- else
- {
- cubes[i, j, k] = new BlockGrass(new Vector3(10 * i, 10 * j, 10 * k));
- }
- }
- lastHeight = currentHeight;
- }
- }
- AddAllCubes();
- }
Advertisement
Add Comment
Please, Sign In to add comment