Combine the two noise functions, we only need one
This commit is contained in:
parent
c637ed37b9
commit
959cbfa15a
1 changed files with 5 additions and 9 deletions
|
@ -17,18 +17,14 @@ type WorldGen interface {
|
||||||
|
|
||||||
// NoiseWorldGen returns a noise based world generator
|
// NoiseWorldGen returns a noise based world generator
|
||||||
type NoiseWorldGen struct {
|
type NoiseWorldGen struct {
|
||||||
// terrainNoise describes the noise function for the terrain
|
// noise describes the noise function
|
||||||
terrainNoise opensimplex.Noise
|
noise opensimplex.Noise
|
||||||
|
|
||||||
// terrainNoise describes the noise function for the terrain
|
|
||||||
objectNoise opensimplex.Noise
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewNoiseWorldGen creates a new noise based world generator
|
// NewNoiseWorldGen creates a new noise based world generator
|
||||||
func NewNoiseWorldGen(seed int64) WorldGen {
|
func NewNoiseWorldGen(seed int64) WorldGen {
|
||||||
return &NoiseWorldGen{
|
return &NoiseWorldGen{
|
||||||
terrainNoise: opensimplex.New(seed),
|
noise: opensimplex.New(seed),
|
||||||
objectNoise: opensimplex.New(seed),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +35,7 @@ const (
|
||||||
|
|
||||||
// GetTile returns the chosen tile at a location
|
// GetTile returns the chosen tile at a location
|
||||||
func (g *NoiseWorldGen) GetTile(v maths.Vector) roveapi.Tile {
|
func (g *NoiseWorldGen) GetTile(v maths.Vector) roveapi.Tile {
|
||||||
t := g.terrainNoise.Eval2(float64(v.X)/terrainNoiseScale, float64(v.Y)/terrainNoiseScale)
|
t := g.noise.Eval2(float64(v.X)/terrainNoiseScale, float64(v.Y)/terrainNoiseScale)
|
||||||
switch {
|
switch {
|
||||||
case t > 0.5:
|
case t > 0.5:
|
||||||
return roveapi.Tile_Gravel
|
return roveapi.Tile_Gravel
|
||||||
|
@ -52,7 +48,7 @@ func (g *NoiseWorldGen) GetTile(v maths.Vector) roveapi.Tile {
|
||||||
|
|
||||||
// GetObject returns the chosen object at a location
|
// GetObject returns the chosen object at a location
|
||||||
func (g *NoiseWorldGen) GetObject(v maths.Vector) Object {
|
func (g *NoiseWorldGen) GetObject(v maths.Vector) Object {
|
||||||
o := g.objectNoise.Eval2(float64(v.X)/objectNoiseScale, float64(v.Y)/objectNoiseScale)
|
o := g.noise.Eval2(float64(v.X)/objectNoiseScale, float64(v.Y)/objectNoiseScale)
|
||||||
var obj = roveapi.Object_ObjectUnknown
|
var obj = roveapi.Object_ObjectUnknown
|
||||||
switch {
|
switch {
|
||||||
case o > 0.6:
|
case o > 0.6:
|
||||||
|
|
Loading…
Add table
Reference in a new issue