From 0305cd01f8438d2c23033958120e61dff4fd2b1b Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Tue, 19 Sep 2023 06:47:50 +0200 Subject: fix: Display selection rect above all entities --- selection.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'selection.go') diff --git a/selection.go b/selection.go index 9b6dbb2..730570a 100644 --- a/selection.go +++ b/selection.go @@ -1,13 +1,15 @@ package main import ( + "image/color" + "github.com/hajimehoshi/ebiten/v2" + "github.com/hajimehoshi/ebiten/v2/vector" "golang.org/x/exp/slog" ) type Selection struct { - IsSelected bool - SelectedImage *ebiten.Image + IsSelected bool } func (e *Entity) SelectMultiple(cursor Point, selection GlobalSelection) { @@ -32,3 +34,11 @@ func (e *Entity) SelectSingle(cursor Point, canBeSelected bool) bool { } return false } + +func DrawSelection(screen *ebiten.Image, e *Entity) { + if e.Image.IsEnabled && e.Position.IsEnabled && e.Selection.IsEnabled { + if e.Selection.Value.IsSelected { + vector.StrokeRect(screen, float32(e.Position.Value.X-5), float32(e.Position.Value.Y-5), 110, 110, 10, color.RGBA{0xff, 0x00, 0x00, 0xff}, false) + } + } +} -- cgit v1.3