use std::rc::Rc; use self::obj_traits::MovingObject; use super::{render::RenderCtx, BG, FG}; pub mod geometry; pub mod obj_traits; pub mod primitive_shapes; pub struct World { objects: Vec>, } impl World { pub fn new() -> Self { Self { objects: Vec::new(), } } pub fn insert(&mut self, obj: Rc) -> usize { self.objects.push(obj); self.objects.len() - 1 } pub fn get(&self, i: usize) -> Rc { self.objects[i].clone() } pub fn get_mut(&mut self, i: usize) -> &mut Rc { &mut self.objects[i] } pub fn draw_all(&self, ctx: &mut RenderCtx<'_, '_>) { self.objects.iter().for_each(|obj| obj.display(ctx)) } }