diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-07-25 12:20:07 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-07-25 12:20:07 +0200 |
| commit | 34455230043d42e4324fc27483688a856851d65d (patch) | |
| tree | 967f1d30f471946ab2843e8023755becd7381075 /entity.go | |
| parent | a4db8814ccb2fc255bd909d8fa827ba23896322f (diff) | |
refactor: ECS bounds
Diffstat (limited to 'entity.go')
| -rw-r--r-- | entity.go | 11 |
1 files changed, 3 insertions, 8 deletions
@@ -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 } |
