From 34455230043d42e4324fc27483688a856851d65d Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Fri, 25 Jul 2025 12:20:07 +0200 Subject: refactor: ECS bounds --- entity.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'entity.go') diff --git a/entity.go b/entity.go index 4657be7..35d2777 100644 --- a/entity.go +++ b/entity.go @@ -11,6 +11,7 @@ import ( type Entity struct { Position ecs.Component[physics.Point] + RelBounds ecs.Component[physics.Rectangle] Image ecs.Component[*ebiten.Image] Selection ecs.Component[selection.Selection] Move ecs.Component[physics.Move] @@ -21,13 +22,6 @@ type Entity struct { Spawn ecs.Component[Spawn] } -func (e Entity) Bounds() physics.Rectangle { - return physics.Rectangle{ - Min: e.Position.Value, - Max: e.Position.Value.Add(e.Image.Value.Bounds().Size()), - } -} - type EntityBuilder struct { entity Entity } @@ -43,8 +37,9 @@ func (b EntityBuilder) WithPosition(position physics.Point) EntityBuilder { return b } -func (b EntityBuilder) WithImage(image *ebiten.Image) EntityBuilder { +func (b EntityBuilder) WithSolid(image *ebiten.Image) EntityBuilder { b.entity.Image = ecs.C(image) + b.entity.RelBounds = ecs.C(image.Bounds()) return b } -- cgit v1.3