diff --git a/simulator/src/main.rs b/simulator/src/main.rs index a3838ca..b499618 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,8 +98,7 @@ impl Robot { } fn crater(&self) -> (f32, f32, f32, Color) { - let tl = self.pose.translation; - (tl.x, tl.y, KILL_RADIUS, ORANGE) + self.weapon.model.crater(self) } fn draw_weapon(&self) { @@ -217,6 +215,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)]