aboutsummaryrefslogtreecommitdiff
path: root/examples/default.go
blob: d291a269831a21d846033fbb44ff5413682a1872 (plain) (blame)
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

package examples

import (
	"image/color"
	"time"

	"age_of_empires/engine"
	"age_of_empires/physics"
	"age_of_empires/selection"
)

func init() {
	Registry["default"] = Entry{
		Name:        "Default",
		Description: "Free play with a town center, iron mine, and gatherer units",
		Build:       buildDefault,
	}
}

func buildDefault(g *engine.Game, deps BuilderDeps) {
	g.ResourceAmount = 150
	g.Camera = engine.Camera{X: 1000, Y: 1000, Zoom: 1.0}
	g.CurrentAction = engine.Selecting
	g.UnitBuilder = deps.UnitBuilder

	ironMineBuilder := engine.NewEntityBuilder().
		WithSolid(engine.NewFilledRectangleImage(physics.Point{X: 100, Y: 100}, color.RGBA{0x80, 0x80, 0x80, 0xff})).
		WithResourceSource(1000).
		WithSelectable("square", selection.Building)
	g.Append(ironMineBuilder.WithPosition(physics.Point{X: 1000, Y: 1000}).Build())

	townCenterBuilder := engine.NewEntityBuilder().
		WithSolid(engine.NewFilledRectangleImage(physics.Point{X: 100, Y: 100}, color.RGBA{0x0, 0x0, 0xff, 0xff})).
		WithResourceStorage().
		WithSelectable("square", selection.Building).
		WithSpawn(engine.NewSpawn(50, 1*time.Second))
	townCenter := g.Append(townCenterBuilder.WithPosition(physics.Point{X: 1000, Y: 2000}).Build())

	_ = townCenter // suppress unused warning; future spawn loop will use it
}