1
2
3
4
5
6
7
8
9
10
11
12
13
14
//! Rectangles collision detection
use crate::geometry::{Rectangle, Vector};

mod bb_collider;

pub use bb_collider::BoundingBoxCollider;

/// Struct implementing this trait can detect rectangles collisions.
pub trait CollisionStrategy {
    /// Does the given rectangle at the given position collide with an already added rectangle?
    fn collides(&self, pos: Vector, r: &Rectangle) -> bool;
    /// Add the given rectangle at the given position to the list of rectangles to detect collisions with.
    fn add(&mut self, pos: Vector, r: Rectangle);
}