diff --git a/simulator/src/main.rs b/simulator/src/main.rs index a3838ca..c7da006 100644 --- a/simulator/src/main.rs +++ b/simulator/src/main.rs @@ -30,7 +30,6 @@ use clap::Parser; use serde::Deserialize; const BOT_RADIUS: f32 = 16.0; -const KILL_RADIUS: f32 = 140.0; trait Mortal { fn collider(&self) -> (&Pose, &dyn Shape); @@ -99,13 +98,7 @@ impl Robot { } fn crater(&self) -> (f32, f32, f32, Color) { - let tl = self.pose.translation; - (tl.x, tl.y, KILL_RADIUS, ORANGE) - } - - fn draw_weapon(&self) { - let tl = self.pose.translation; - draw_circle(tl.x, tl.y, KILL_RADIUS, ORANGE); + self.weapon.model.crater(self) } fn weapon<'a>(&self, peers: impl Iterator) { @@ -217,6 +210,22 @@ impl WeaponType { }, } } + pub fn crater(&self, robot: &Robot) -> (f32, f32, f32, Color) { + match self { + WeaponType::Ball{radius} => { + let tl = robot.pose.translation; + (tl.x, tl.y, *radius, ORANGE) + }, + WeaponType::Lazer{range} => { + let tl = robot.pose.translation; + (tl.x, tl.y, *range, LIGHTGRAY) + }, + WeaponType::ForwardBall{radius} => { + let tl = robot.view_end(); + (tl.x, tl.y, *radius, ORANGE) + }, + } + } } #[derive(Deserialize, Clone)]