tins2020/game.go

62 lines
887 B
Go
Raw Normal View History

2020-05-08 16:38:26 +00:00
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,
2020-05-09 05:48:02 +00:00
beta: 2.13,
2020-05-08 16:38:26 +00:00
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
}