Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------------------------------------
- ------------------- terrain generator ----------
- ------------------99% BY xLEGOx --------------
- ------------------Modified by JKM103----------
- --- how varied the terrain should be
- variance = 3
- _G.Terrain = {}
- for i = 1, 35 do
- Terrain[i] = {}
- for j = 1, 35 do
- Terrain[i][j] = {h = 0}
- end
- end
- slope = 0.7
- num_itts = 0.1
- function Diamond(x, y, eachside)
- num_itts = num_itts + 1
- --print(num_itts, "->", eachside)
- --wait()
- local h_mul = math.random(-slope*eachside, slope*eachside)
- for _x_ = -eachside, eachside do
- for _y_ = -eachside, eachside do
- local _x, _y = _x_ + x, _y_ + y
- local max = math.max(math.abs(_x_), math.abs(_y_))
- local h_mod = 1.1 - (max / eachside)
- Terrain[_x][_y].h = Terrain[_x][_y].h + h_mod * h_mul
- end
- end
- if eachside > 1 then
- --[[]]Diamond(x + eachside/2, y + eachside/2, eachside/2)
- Diamond(x - eachside/2, y - eachside/2, eachside/2)
- Diamond(x - eachside/2, y + eachside/2, eachside/2)
- Diamond(x + eachside/2, y - eachside/2, eachside/2)
- end
- end
- game.Players.ChildAdded:wait()
- Diamond(17, 17, 17)
- for x = 1, 35 do
- for y = 1, 35 do
- wait()
- DrawTriangle(Vector3.new(x*10, Terrain[x][y].h*10, y*10), Vector3.new(x*10, Terrain[x][y+1].h*10, (y+1)*10), Vector3.new((x+1)*10, Terrain[x+1][y].h*10, y*10))
- DrawTriangle(Vector3.new((x+1)*10, Terrain[x+1][y+1].h*10, (y+1)*10), Vector3.new(x*10, Terrain[x][y+1].h*10, (y+1)*10), Vector3.new((x+1)*10, Terrain[x+1][y].h*10, y*10))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement