worldgen water, fixes

This commit is contained in:
2022-01-28 15:24:03 +08:00
parent 7b6c16789c
commit 904221ac14
13 changed files with 245 additions and 72 deletions

View File

@ -4,6 +4,7 @@ import (
"sync"
packworld "edgaru089.ml/go/gl01/internal/world"
"edgaru089.ml/go/gl01/internal/world/blocks"
"github.com/aquilax/go-perlin"
)
@ -15,8 +16,8 @@ const (
AltitudeDensity = 10 // Density of the noise in altitude
Sealevel = 63 // Space with Y=63 and lower should be the sea
Highest = 72 // Highest part of the terrain
Lowest = 56 // Lowest part of the terrain
Highest = 84 // Highest part of the terrain
Lowest = 60 // Lowest part of the terrain
)
var perlins map[int64]*perlin.Perlin
@ -54,21 +55,30 @@ func Chunk(chunk *packworld.Chunk, world *packworld.World, seed int64) {
float64(offZ+z)/AltitudeDensity))
//log.Printf("height = %d (noise=%.5f)", height, p.Noise2D(float64(offX+x), float64(offZ+z)))
// water
for y := Sealevel; y > height; y-- {
chunk.Id[x][y][z] = blocks.Water
}
// covering dirt
chunk.Id[x][height][z] = packworld.BlockGrass
//chunk.Id[x][height][z] = packworld.BlockDebugDir
chunk.Id[x][height-1][z] = packworld.BlockDirt
chunk.Id[x][height-2][z] = packworld.BlockDirt
chunk.Id[x][height-3][z] = packworld.BlockDirt
if height >= Sealevel {
chunk.Id[x][height][z] = blocks.Grass
} else {
chunk.Id[x][height][z] = blocks.Dirt
}
//chunk.Id[x][height][z] = blocks.DebugDir
chunk.Id[x][height-1][z] = blocks.Dirt
chunk.Id[x][height-2][z] = blocks.Dirt
chunk.Id[x][height-3][z] = blocks.Dirt
height -= 4
// stone in the middle
for y := height; y >= 1; y-- {
chunk.Id[x][y][z] = packworld.BlockStone
chunk.Id[x][y][z] = blocks.Stone
}
// bedrock at the bottom
chunk.Id[x][0][z] = packworld.BlockBedrock
chunk.Id[x][0][z] = blocks.Bedrock
// plant trees
if height >= 50 && height <= 70 {