forwardball craters
This commit is contained in:
parent
bd22161bbc
commit
f2d3ea77cb
1 changed files with 17 additions and 8 deletions
|
|
@ -30,7 +30,6 @@ use clap::Parser;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
const BOT_RADIUS: f32 = 16.0;
|
const BOT_RADIUS: f32 = 16.0;
|
||||||
const KILL_RADIUS: f32 = 140.0;
|
|
||||||
|
|
||||||
trait Mortal {
|
trait Mortal {
|
||||||
fn collider(&self) -> (&Pose, &dyn Shape);
|
fn collider(&self) -> (&Pose, &dyn Shape);
|
||||||
|
|
@ -99,13 +98,7 @@ impl Robot {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn crater(&self) -> (f32, f32, f32, Color) {
|
fn crater(&self) -> (f32, f32, f32, Color) {
|
||||||
let tl = self.pose.translation;
|
self.weapon.model.crater(self)
|
||||||
(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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn weapon<'a>(&self, peers: impl Iterator<Item = &'a dyn Mortal>) {
|
fn weapon<'a>(&self, peers: impl Iterator<Item = &'a dyn Mortal>) {
|
||||||
|
|
@ -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)]
|
#[derive(Deserialize, Clone)]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue