51 lines
963 B
Go
51 lines
963 B
Go
package colliders
|
|
|
|
import (
|
|
"fluids/gamedata"
|
|
"image"
|
|
)
|
|
|
|
type BaseRectCollider struct {
|
|
position gamedata.Vector
|
|
dimensions gamedata.Vector
|
|
iscontainer bool
|
|
}
|
|
|
|
func (b *BaseRectCollider) SetContainer(v bool) {
|
|
b.iscontainer = v
|
|
}
|
|
|
|
func (b *BaseRectCollider) SetPosition(p gamedata.Vector) {
|
|
b.position = p
|
|
}
|
|
|
|
func (b *BaseRectCollider) GetPosition() gamedata.Vector {
|
|
return b.position
|
|
}
|
|
|
|
func (b *BaseRectCollider) SetDimensions(d gamedata.Vector) {
|
|
b.dimensions = d
|
|
}
|
|
|
|
func (b *BaseRectCollider) GetDimensions() gamedata.Vector {
|
|
return b.dimensions
|
|
}
|
|
|
|
func (b *BaseRectCollider) GetBounds() image.Rectangle {
|
|
r := image.Rectangle{
|
|
Min: image.Point{
|
|
X: int(b.position.X - b.dimensions.X/2),
|
|
Y: int(b.position.Y - b.dimensions.Y/2),
|
|
},
|
|
Max: image.Point{
|
|
X: int(b.position.X + b.dimensions.X/2),
|
|
Y: int(b.position.Y + b.dimensions.Y/2),
|
|
},
|
|
}
|
|
return r
|
|
}
|
|
|
|
func (b *BaseRectCollider) IsContainer() bool {
|
|
return b.iscontainer
|
|
}
|