/
run.go
79 lines (64 loc) · 1.54 KB
/
run.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
package flocking
import (
"image"
"log"
"github.com/mlange-42/arche-demo/common"
"github.com/mlange-42/arche-demo/common/systems"
"github.com/mlange-42/arche-model/model"
"github.com/mlange-42/arche/ecs"
)
const (
screenWidth = 880
screenHeight = 480
)
func Run() {
game := common.NewGame(
model.New(), screenWidth, screenHeight,
)
ecs.AddResource(&game.Model.World, &game.Screen)
ecs.AddResource(&game.Model.World, &game.Mouse)
img := common.Image{
Image: image.NewRGBA(game.Screen.Image.Bounds()),
Width: game.Screen.Width,
Height: game.Screen.Height,
}
ecs.AddResource(&game.Model.World, &img)
images := NewImages()
ecs.AddResource(&game.Model.World, &images)
game.Model.AddSystem(&SysInitBoids{Count: 300})
game.Model.AddSystem(&SysNeighbors{
Neighbors: 8,
Radius: 50,
BuildStep: 4,
})
game.Model.AddSystem(&SysMoveBoids{
Speed: 1,
UpdateInterval: 4,
SeparationDist: 8,
SeparationAngle: 3,
CohesionAngle: 1.5,
AlignmentAngle: 2,
WallDist: 80,
WallAngle: 12,
MouseDist: 100,
MouseAngle: 5,
})
//game.Model.AddUISystem(&boids.UISysDrawBoids{})
game.Model.AddUISystem(&UISysDrawBoidsLines{})
/*game.Model.AddUISystem(&boids.UISysDrawBoid{
Radius: 60,
})*/
game.Model.AddUISystem(&UISysManagePause{})
game.Model.AddUISystem(&systems.SimSpeed{
InitialExponent: 0,
MinExponent: -2,
MaxExponent: 2,
})
game.Model.AddUISystem(&systems.DrawInfo{
Offset: image.Point{X: 800, Y: 0},
})
game.Initialize()
if err := game.Run(); err != nil {
log.Fatal(err)
}
}