diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-07-05 09:34:48 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-07-05 09:34:48 +0200 |
| commit | b3e70bf4cf7e790fa8b5239c05b6c7b917f19635 (patch) | |
| tree | 2b000ffb16cf3c4d48ad63ca45c55ae68f886936 | |
| parent | 56b3d85afaf260be93e46e2b930f79ade461789b (diff) | |
Simple refactor
| -rw-r--r-- | selection.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/selection.go b/selection.go index 329f6d7..ef270c6 100644 --- a/selection.go +++ b/selection.go @@ -31,7 +31,7 @@ func (e *Entity) SelectSingle(cursor physics.Point, canBeSelected bool) bool { return false } e.Selection.Value.IsSelected = false - if !canBeSelected || cursor.In(e.Bounds()) { + if !canBeSelected || !cursor.In(e.Bounds()) { return false } e.Selection.Value.IsSelected = true @@ -40,11 +40,12 @@ func (e *Entity) SelectSingle(cursor physics.Point, canBeSelected bool) bool { } func DrawSelection(screen *ebiten.Image, e *Entity) { - if e.Image.IsEnabled && e.Position.IsEnabled && e.Selection.IsEnabled { - if 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)) - screen.DrawImage(e.Selection.Value.Halo, opt) - } + if !e.Image.IsEnabled || !e.Position.IsEnabled || !e.Selection.IsEnabled { + return + } + if 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)) + screen.DrawImage(e.Selection.Value.Halo, opt) } } |
