teki_common/utils/
collision.rs

1use vector2d::Vector2D;
2
3pub struct CollBox {
4    pub top_left: Vector2D<i32>,
5    pub size: Vector2D<i32>,
6}
7
8impl CollBox {
9    pub fn check_collision(&self, target: &CollBox) -> bool {
10        let br1 = self.top_left + self.size;
11        let br2 = target.top_left + target.size;
12
13        self.top_left.x < br2.x
14            && self.top_left.y < br2.y
15            && target.top_left.x < br1.x
16            && target.top_left.y < br1.y
17    }
18}