From 34455230043d42e4324fc27483688a856851d65d Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Fri, 25 Jul 2025 12:20:07 +0200 Subject: refactor: ECS bounds --- main.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 86dc59b..e4c82f3 100644 --- a/main.go +++ b/main.go @@ -78,13 +78,13 @@ func (g *Game) updateSelecting(cursor physics.Point, moveMap physics.MoveMap) { if g.Selection.IsActive && physics.Distance(g.Selection.Start, cursor) > 10 { selector := selection.NewMultiple(g.Selection.Start, cursor) for _, e := range g.Entities { - selector.Preselect(e.Position, e.Bounds(), &e.Selection) + selector.Preselect(e.Position, e.RelBounds, &e.Selection) } selector.Select() } else { selector := selection.NewSingle(cursor) for _, e := range g.Entities { - selector.Select(e.Position, e.Bounds(), &e.Selection) + selector.Select(e.Position, e.RelBounds, &e.Selection) } } g.Selection.IsActive = false @@ -166,11 +166,11 @@ func main() { s, err := text.NewGoTextFaceSource(bytes.NewReader(goregular.TTF)) kcore.Expect(err, "failed to create font source") game.FaceSource = s - ironMine := NewEntityBuilder().WithPosition(physics.Point{X: 1000, Y: 1000}).WithImage(NewFilledRectangleImage(physics.Point{X: 100, Y: 100}, color.RGBA{0x80, 0x80, 0x80, 0xff})).WithResourceSource(1000).WithSelection("square", selection.Building).Build() + ironMine := NewEntityBuilder().WithPosition(physics.Point{X: 1000, Y: 1000}).WithSolid(NewFilledRectangleImage(physics.Point{X: 100, Y: 100}, color.RGBA{0x80, 0x80, 0x80, 0xff})).WithResourceSource(1000).WithSelection("square", selection.Building).Build() game.Entities = append(game.Entities, &ironMine) - townCenter := NewEntityBuilder().WithPosition(physics.Point{X: 1000, Y: 2000}).WithImage(NewFilledRectangleImage(physics.Point{X: 100, Y: 100}, color.RGBA{0x0, 0x0, 0xff, 0xff})).WithResourceStorage().WithSelection("square", selection.Building).WithSpawn(NewSpawn(50, 1*time.Second)).Build() + townCenter := NewEntityBuilder().WithPosition(physics.Point{X: 1000, Y: 2000}).WithSolid(NewFilledRectangleImage(physics.Point{X: 100, Y: 100}, color.RGBA{0x0, 0x0, 0xff, 0xff})).WithResourceStorage().WithSelection("square", selection.Building).WithSpawn(NewSpawn(50, 1*time.Second)).Build() game.Entities = append(game.Entities, &townCenter) - game.UnitBuilder = NewEntityBuilder().WithImage(NewFilledCircleImage(100, color.White)).WithSelection("round", selection.Unit).WithMove().WithOrder().WithResourceGatherer(15) + game.UnitBuilder = NewEntityBuilder().WithSolid(NewFilledCircleImage(100, color.White)).WithSelection("round", selection.Unit).WithMove().WithOrder().WithResourceGatherer(15) for i := 0; i < 0; i++ { spawnPosition, _ := physics.Closest(townCenter.Position.Value, physics.AdjacentPoints(townCenter.Position.Value), game.getMoveMap()) person := game.UnitBuilder.Build() -- cgit v1.3