Initial commit.
This commit is contained in:
50
colliders/baserectcollider.go
Normal file
50
colliders/baserectcollider.go
Normal file
@@ -0,0 +1,50 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user