world: fix worldgen

This commit is contained in:
2022-02-02 01:52:02 +08:00
parent 37ee76e9fc
commit 0e4e17ced7
3 changed files with 51 additions and 8 deletions

View File

@ -13,11 +13,11 @@ const (
Beta = 2 // harmonic scaling/spacing
N = 3 // iterations
AltitudeDensity = 10 // Density of the noise in altitude
AltitudeDensity = 20 // Density of the noise in altitude
Sealevel = 63 // Space with Y=63 and lower should be the sea
Highest = 84 // Highest part of the terrain
Lowest = 60 // Lowest part of the terrain
Highest = 74 // Highest part of the terrain
Lowest = 54 // Lowest part of the terrain
)
var perlins map[int64]*perlin.Perlin
@ -50,10 +50,10 @@ func Chunk(chunk *packworld.Chunk, world *packworld.World, seed int64) {
for x := 0; x < packworld.ChunkSizeX; x++ {
for z := 0; z < packworld.ChunkSizeZ; z++ {
height := Lowest + int(float64(Highest-Lowest)*p.Noise2D(
height := Lowest + int(float64(Highest-Lowest)*(p.Noise2D(
float64(offX+x)/AltitudeDensity,
float64(offZ+z)/AltitudeDensity))
//log.Printf("height = %d (noise=%.5f)", height, p.Noise2D(float64(offX+x), float64(offZ+z)))
float64(offZ+z)/AltitudeDensity)/2+0.5))
//log.Printf("height = %d (noise=%.5f)", height, p.Noise2D(float64(offX+x)/AltitudeDensity, float64(offZ+z)/AltitudeDensity)/2+0.5)
// water
for y := Sealevel; y > height; y-- {