mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 08:41:34 +11:00
add collision function
This commit is contained in:
parent
2974711a38
commit
631bf2bae2
|
@ -656,6 +656,13 @@ impl<T: Number> Rect<T> {
|
|||
&& point.y < self.position.y + self.size.y
|
||||
}
|
||||
|
||||
pub fn touches(self, other: Rect<T>) -> bool {
|
||||
self.position.x < other.position.x + other.size.x
|
||||
&& self.position.x + self.size.x > other.position.x
|
||||
&& self.position.y < other.position.y + other.size.y
|
||||
&& self.position.y + self.size.y > self.position.y
|
||||
}
|
||||
|
||||
pub fn overlapping_rect(&self, other: Rect<T>) -> Rect<T> {
|
||||
fn max<E: Number>(x: E, y: E) -> E {
|
||||
if x > y {
|
||||
|
|
Loading…
Reference in a new issue