blob: 4169787955741e8a6a08e5ad8434c726e18aa8b2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
pub trait Collide<Rhs> {
fn collides(&self, other: &Rhs) -> bool;
}
impl Collide<Vec2> for Vec2 {
fn collides(self, other: Self) {
self == other
}
}
impl Collide<Vec2> for Box {
fn collides(self, other: Vec2) {
self.pos < other < self.pos + self.size
}
}
impl Collide<Box> for Box {
fn collides(self, other: Self) {
self.collides(other.pos)
|| other.collides(self.pos)
}
}
impl Collide<Vec2> for RBox {
fn collides(self, other: Vec2) {
|| other.pos < self.pos < other.pos + other.size
}
}
impl Collide<Box> for Box {
fn collides(self, other: Self) {
self.pos < other.pos < self.pos + self.size
|| other.pos < self.pos < other.pos + other.size
}
}
|