62 lines
884 B
Go
62 lines
884 B
Go
package tins2020
|
|
|
|
import (
|
|
"math/rand"
|
|
|
|
"opslag.de/schobers/geom/noise"
|
|
)
|
|
|
|
type Game struct {
|
|
Terrain *Map
|
|
Flowers []Flower
|
|
Bees []Bee
|
|
}
|
|
|
|
type Map struct {
|
|
Temp *NoiseMap
|
|
Humid *NoiseMap
|
|
}
|
|
|
|
type NoiseMap struct {
|
|
noise *noise.Perlin
|
|
alpha, beta float64
|
|
harmonics int
|
|
}
|
|
|
|
func NewNoiseMap(seed int64) *NoiseMap {
|
|
return &NoiseMap{
|
|
noise: noise.NewPerlin(seed),
|
|
alpha: 2,
|
|
beta: 2,
|
|
harmonics: 4,
|
|
}
|
|
}
|
|
|
|
func (m *NoiseMap) Value(x, y int) float64 {
|
|
return m.noise.Noise2D(float64(x), float64(y), m.alpha, m.beta, m.harmonics)
|
|
}
|
|
|
|
func NewGame() *Game {
|
|
terrain := &Map{
|
|
Temp: NewNoiseMap(rand.Int63()),
|
|
Humid: NewNoiseMap(rand.Int63()),
|
|
}
|
|
return &Game{
|
|
Terrain: terrain,
|
|
Flowers: []Flower{},
|
|
Bees: []Bee{},
|
|
}
|
|
}
|
|
|
|
type PointF struct {
|
|
X, Y float32
|
|
}
|
|
|
|
type Flower struct {
|
|
Location PointF
|
|
}
|
|
|
|
type Bee struct {
|
|
Location PointF
|
|
}
|