-
Notifications
You must be signed in to change notification settings - Fork 0
/
maps.go
80 lines (72 loc) · 1.4 KB
/
maps.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package galaxy
import (
"math/rand"
)
func NewSquareGameMap() *Game {
return &Game{
Planets: map[string]*Planet{
"a": &Planet{
Center: Vec2{5, 5},
Player: 1,
Units: 100,
Size: 2,
Capacity: 500,
},
"b": &Planet{
Center: Vec2{20, 5},
Player: 0,
Units: 100,
Size: 1,
Capacity: 500,
},
"c": &Planet{
Center: Vec2{5, 20},
Player: 0,
Units: 100,
Size: 1,
Capacity: 500,
},
"d": &Planet{
Center: Vec2{20, 20},
Player: 2,
Units: 100,
Size: 2,
Capacity: 500,
},
},
}
}
func NewRandomMap(width, height float32) *Game {
g := &Game{Planets: map[string]*Planet{}}
letters := "cdefghijklmno"
for _, letter := range letters {
x := rand.Float32() * width
y := rand.Float32() * height
g.Planets[string(letter)] = &Planet{
Center: Vec2{x, y},
Player: 0,
Units: rand.Float32() * 100,
Size: rand.Float32() * 2,
Capacity: 500 + 500*rand.Float32(),
}
}
x := rand.Float32() * width
y := rand.Float32() * height
g.Planets["a"] = &Planet{
Center: Vec2{x, y},
Player: 1,
Units: 100,
Size: 2,
Capacity: 500 + 500*rand.Float32(),
}
x = rand.Float32() * width
y = rand.Float32() * height
g.Planets["b"] = &Planet{
Center: Vec2{x, y},
Player: 2,
Units: 100,
Size: 2,
Capacity: 500 + 500*rand.Float32(),
}
return g
}