use basic_collision::*; #[derive(Debug)] pub struct Block { x: f32, y: f32, width: f32, height: f32, } impl Block { pub fn new(x: f32, y: f32, width: f32, height: f32) -> Block { Block { x, y, width, height } } } impl Object for Block { fn boundary(&self) -> Boundary { Boundary::new(self.x, self.y, self.width, self.height) } } fn main() { let blocks: Vec> = vec![ Box::new(Block::new(100., 150., 60., 50.)), Box::new(Block::new(150., 150., 40., 50.)), Box::new(Block::new(200., 150., 60., 50.)), ]; for block in blocks.iter() { if block.does_collide(&blocks[..]) { println!("Collision occurred!"); } } }