aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2025-07-09 08:58:14 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2025-07-09 08:58:14 +0200
commit9f30f800443e6496bbba264a375c126cb26b1760 (patch)
treebc0da293f552a0ecf7cac356a6747c109ce9eb0c /main.go
parent057adf65468e7b6ec544686b80433093a9f9deab (diff)
Spawn target for newly spawned units
Diffstat (limited to 'main.go')
-rw-r--r--main.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/main.go b/main.go
index f2eb907..cecc1d6 100644
--- a/main.go
+++ b/main.go
@@ -91,7 +91,10 @@ func (g *Game) updateSelecting(cursor physics.Point, moveMap physics.MoveMap) {
entityAtDestination := g.entityAt(destination)
slog.Info("destination", slog.String("destination", destination.String()))
for _, e := range g.Entities {
- e.MainAction(g, destination, entityAtDestination, moveMap)
+ if e.Selection.IsEnabled && e.Selection.Value.IsSelected {
+ e.MainAction(g, destination, entityAtDestination, moveMap)
+
+ }
}
}
if inpututil.IsMouseButtonJustReleased(ebiten.MouseButtonLeft) {
@@ -179,7 +182,9 @@ func main() {
iconImg, _, err := image.Decode(icon)
kcore.Expect(err, "failed to decode icon")
ebiten.SetWindowIcon([]image.Image{iconImg})
- game := &Game{}
+ game := &Game{
+ ResourceAmount: 150,
+ }
s, err := text.NewGoTextFaceSource(bytes.NewReader(goregular.TTF))
kcore.Expect(err, "failed to create font source")
game.FaceSource = s
@@ -187,10 +192,9 @@ func main() {
game.Entities = append(game.Entities, &ironMine)
townCenter := EntityBuilder{}.WithPosition(physics.Point{X: 1000, Y: 2000}).WithImage(NewFilledRectangleImage(physics.Point{X: 100, Y: 100}, color.RGBA{0x0, 0x0, 0xff, 0xff})).WithResourceStorage().WithSelection("square").WithSpawn(NewSpawn(50, 5*time.Second)).Build()
game.Entities = append(game.Entities, &townCenter)
- spawnPosition, _ := game.Closest(townCenter.Position.Value, physics.AdjacentPoints(townCenter.Position.Value))
game.UnitBuilder = EntityBuilder{}.WithImage(NewFilledCircleImage(100, color.White)).WithSelection("round").WithMove().WithOrder().WithResourceGatherer(15)
- for i := 0; i < 2; i++ {
- spawnPosition, _ = game.Closest(townCenter.Position.Value, physics.AdjacentPoints(townCenter.Position.Value))
+ for i := 0; i < 0; i++ {
+ spawnPosition, _ := game.Closest(townCenter.Position.Value, physics.AdjacentPoints(townCenter.Position.Value))
person := game.UnitBuilder.Build()
person.Position = ecs.C(spawnPosition)
game.Entities = append(game.Entities, &person)