From a5fef758107888853c14a592696b45768ef56df8 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Fri, 4 Jul 2025 17:55:53 +0200 Subject: Refactor into packages --- selection.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'selection.go') diff --git a/selection.go b/selection.go index e41fce3..91f35fe 100644 --- a/selection.go +++ b/selection.go @@ -1,6 +1,8 @@ package main import ( + "age_of_empires/physics" + "github.com/hajimehoshi/ebiten/v2" "golang.org/x/exp/slog" ) @@ -12,10 +14,10 @@ type Selection struct { Halo *ebiten.Image } -func (e *Entity) SelectMultiple(cursor Point, selection GlobalSelection) { +func (e *Entity) SelectMultiple(cursor physics.Point, selection GlobalSelection) { if e.Selection.IsEnabled { e.Selection.Value.IsSelected = false - selectionBounds := Rectangle{selection.Start, cursor}.Canon() + selectionBounds := physics.Rectangle{Min:selection.Start, Max:cursor}.Canon() if selectionBounds.Overlaps(e.Bounds()) { e.Selection.Value.IsSelected = true slog.Info("entity selected", slog.String("position", e.Position.Value.String())) @@ -23,7 +25,7 @@ func (e *Entity) SelectMultiple(cursor Point, selection GlobalSelection) { } } -func (e *Entity) SelectSingle(cursor Point, canBeSelected bool) bool { +func (e *Entity) SelectSingle(cursor physics.Point, canBeSelected bool) bool { if e.Selection.IsEnabled { e.Selection.Value.IsSelected = false if canBeSelected && cursor.In(e.Bounds()) { -- cgit v1.3