From 2b05b9d8aa47f6cc9d768c6758f1cca4e8721a4c Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Mon, 7 Jul 2025 09:39:29 +0200 Subject: Regroup drawing --- main.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index aef9968..09eb16d 100644 --- a/main.go +++ b/main.go @@ -165,10 +165,7 @@ func (g *Game) Draw(screen *ebiten.Image) { cursor := physics.Point{X: x, Y: y} screen.Fill(soilColor) for _, e := range g.Entities { - Draw(screen, e) - } - for _, e := range g.Entities { - DrawSelection(screen, e) + e.Draw(g, screen) } for _, e := range g.Entities { DrawMove(screen, e) @@ -209,10 +206,12 @@ func main() { kcore.Expect(err, "failed to create font source") game.FaceSource = s ironImage := NewFilledRectangleImage(physics.Point{X: 100, Y: 100}, color.RGBA{0x80, 0x80, 0x80, 0xff}) + ironSelectionHalo := NewStrokeRectangleImage(physics.Point{X: 110, Y: 110}, SELECTION_HALO_WIDTH, color.RGBA{0xff, 0x00, 0x00, 0xff}) ironMine := Entity{ Position: ecs.C(physics.Point{X: 1000, Y: 1000}), Image: ecs.C(ironImage), ResourceSource: ecs.C(ResourceSource{Remaining: 1000}), + Selection: ecs.C(Selection{IsSelected: false, Halo: ironSelectionHalo}), } game.Entities = append(game.Entities, &ironMine) storageImage := NewFilledRectangleImage(physics.Point{X: 100, Y: 100}, color.RGBA{0x00, 0x00, 0xff, 0xff}) -- cgit v1.3