aboutsummaryrefslogtreecommitdiff
path: root/selection.go
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2023-10-06 07:04:35 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2023-10-06 07:04:35 +0200
commitbf546b1b4c92d3d358a85b6b760dad01bc95ea7c (patch)
tree898680c3e7b5c32ff206cbd075023b15f3356f4e /selection.go
parent7b805f2bcc3b25c9077ec39fc0693091a4e05b0a (diff)
feat(selection): Use circle for units
Diffstat (limited to 'selection.go')
-rw-r--r--selection.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/selection.go b/selection.go
index 730570a..23e98aa 100644
--- a/selection.go
+++ b/selection.go
@@ -1,15 +1,15 @@
package main
import (
- "image/color"
-
"github.com/hajimehoshi/ebiten/v2"
- "github.com/hajimehoshi/ebiten/v2/vector"
"golang.org/x/exp/slog"
)
+const SELECTION_HALO_SIZE = 10
+
type Selection struct {
IsSelected bool
+ Halo *ebiten.Image
}
func (e *Entity) SelectMultiple(cursor Point, selection GlobalSelection) {
@@ -38,7 +38,9 @@ func (e *Entity) SelectSingle(cursor 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 {
- 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)
+ opt := &ebiten.DrawImageOptions{}
+ opt.GeoM.Translate(float64(e.Position.Value.X-SELECTION_HALO_SIZE/2), float64(e.Position.Value.Y-SELECTION_HALO_SIZE/2))
+ screen.DrawImage(e.Selection.Value.Halo, opt)
}
}
}