From a4db8814ccb2fc255bd909d8fa827ba23896322f Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Fri, 25 Jul 2025 12:03:32 +0200 Subject: feat: Draw spawn target --- README.md | 2 +- draw.go | 6 +++++- entity.go | 6 +++--- selection/selection.go | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3fa232a..b786d47 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ - bigger map - move the map view - ecs array: on delete, replace by last and update id->index map -- `ecs.Component[*ebiten.Image]` drop the pointer +- collision based move w smaller accuracy - perf: look for nil comparison -> more data oriented - perf: keep a short array of selected diff --git a/draw.go b/draw.go index 528955e..8545af7 100644 --- a/draw.go +++ b/draw.go @@ -20,7 +20,7 @@ func (e *Entity) Draw(g *Game, screen *ebiten.Image) { screen.DrawImage(e.Image.Value, op) if e.Selection.IsEnabled && e.Selection.Value.IsSelected { opt := &ebiten.DrawImageOptions{} - opt.GeoM.Translate(float64(e.Position.Value.X-selection.HALO_WIDTH/2), float64(e.Position.Value.Y-selection.HALO_WIDTH/2)) + opt.GeoM.Translate(float64(e.Position.Value.X-selection.HaloWidth/2), float64(e.Position.Value.Y-selection.HaloWidth/2)) screen.DrawImage(e.Selection.Value.Halo, opt) if e.ResourceSource.IsEnabled { resourceText := fmt.Sprintf("%d", e.ResourceSource.Value.Remaining) @@ -41,6 +41,10 @@ func (e *Entity) Draw(g *Game, screen *ebiten.Image) { Source: g.FaceSource, Size: 40, }, op) + if e.Spawn.Value.SpawnTarget.IsEnabled { + spawnTarget := e.Spawn.Value.SpawnTarget.Value + vector.DrawFilledCircle(screen, float32(spawnTarget.X+50), float32(spawnTarget.Y+50), 30, Red, true) + } } if e.Move.Value.IsActive { last := e.Position.Value diff --git a/entity.go b/entity.go index 2b120f5..4657be7 100644 --- a/entity.go +++ b/entity.go @@ -48,7 +48,7 @@ func (b EntityBuilder) WithImage(image *ebiten.Image) EntityBuilder { return b } -var red = color.RGBA{0xff, 0x00, 0x00, 0xff} +var Red = color.RGBA{0xff, 0x00, 0x00, 0xff} func (b EntityBuilder) WithSelection(haloKind string, priority selection.Priority) EntityBuilder { b.entity.Selection = ecs.C(selection.Selection{ @@ -58,9 +58,9 @@ func (b EntityBuilder) WithSelection(haloKind string, priority selection.Priorit }) switch haloKind { case "round": - b.entity.Selection.Value.Halo = NewStrokeCircleImage(110, selection.HALO_WIDTH, red) + b.entity.Selection.Value.Halo = NewStrokeCircleImage(110, selection.HaloWidth, Red) case "square": - b.entity.Selection.Value.Halo = NewStrokeRectangleImage(physics.Point{X: 110, Y: 110}, selection.HALO_WIDTH, red) + b.entity.Selection.Value.Halo = NewStrokeRectangleImage(physics.Point{X: 110, Y: 110}, selection.HaloWidth, Red) } return b } diff --git a/selection/selection.go b/selection/selection.go index 2755110..d8fa6fe 100644 --- a/selection/selection.go +++ b/selection/selection.go @@ -8,7 +8,7 @@ import ( "github.com/hajimehoshi/ebiten/v2" ) -const HALO_WIDTH = 10 +const HaloWidth = 10 type Priority int -- cgit v1.3