aboutsummaryrefslogtreecommitdiff
path: root/entity.go
diff options
context:
space:
mode:
Diffstat (limited to 'entity.go')
-rw-r--r--entity.go11
1 files changed, 3 insertions, 8 deletions
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
}