diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-07-04 17:55:53 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-07-04 23:02:21 +0200 |
| commit | a5fef758107888853c14a592696b45768ef56df8 (patch) | |
| tree | 9d1fd0b0abb49ce6814b8868926bf7af83611303 /selection.go | |
| parent | e3f14fc0b375b4b7c2204a669d058ac124b78e92 (diff) | |
Refactor into packages
Diffstat (limited to 'selection.go')
| -rw-r--r-- | selection.go | 8 |
1 files changed, 5 insertions, 3 deletions
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()) { |
