game generation process

This commit is contained in:
Ilia Denisov
2025-09-25 02:13:16 +03:00
parent 99035fd95d
commit 46066d890b
12 changed files with 206 additions and 101 deletions
-33
View File
@@ -20,30 +20,6 @@ type Coordinate struct {
X, Y float64
}
type PlanetClass int
const (
PlanetClassHW PlanetClass = iota
PlanetClassDW
PlanetClassGiant
PlanetClassBig
PlanetClassNormal
PlanetClassRich
PlanetClassAsterioid
)
type Planet struct {
PlanetClass PlanetClass
Position Coordinate
Size float64
Resources float64 // Сырьё
}
type PlanetarySystem struct {
HW Planet
DW []Planet
}
func NewMap(width, height, players uint32) (*Map, error) {
p, err := plotter.NewPlotter(width, height, defaultFactor)
if err != nil {
@@ -93,15 +69,6 @@ func (m Map) ShortDistance(from, to Coordinate) float64 {
return math.Sqrt(math.Pow(dx, 2) + math.Pow(dy, 2))
}
func NewPlanet(pc PlanetClass, c Coordinate, size, resources float64) Planet {
return Planet{
PlanetClass: pc,
Position: c,
Size: size,
Resources: resources,
}
}
// RandI returns a random float64 value between min and max
func RandI(min, max float64) float64 {
return min + rand.Float64()*(max-min)