-
Notifications
You must be signed in to change notification settings - Fork 0
/
universe.go
45 lines (35 loc) · 1006 Bytes
/
universe.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package spacegame
import "github.com/faiface/pixel"
// A graph of solar systems
type Universe struct {
systems map[string]*SolarSystem
coordinates map[string]pixel.Vec
}
func NewUniverse(rm ResourceManager) *Universe {
systems := make(map[string]*SolarSystem)
coordinates := make(map[string]pixel.Vec)
// TODO: This section comes from somewhere else
name := "Vera"
veraSystem, err := LoadSystem("data/resources/universe/systems/Vera.json")
if err != nil {
panic(err) // TODO: Don't panic!
}
systems[name] = veraSystem
coordinates[name] = pixel.V(0, 0)
universe := Universe{
systems: systems,
coordinates: coordinates,
}
return &universe
}
func (uv *Universe) Systems() map[string]*SolarSystem {
return uv.systems
}
func (uv *Universe) SystemCoordinates() map[string]pixel.Vec {
return uv.coordinates
}
func (uv *Universe) addSystem(system *SolarSystem, coordinates pixel.Vec) {
name := system.Name()
uv.systems[name] = system
uv.coordinates[name] = coordinates
}