add permanent weapon marks
This commit is contained in:
parent
aef4cffd43
commit
0f831acf45
1 changed files with 15 additions and 1 deletions
|
|
@ -84,6 +84,11 @@ impl Robot {
|
|||
.map(|contact| contact.point1.distance(self.pose.translation)).reduce(|x: f32,y: f32| x.min(y))
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
@ -166,6 +171,8 @@ async fn run_simulation() -> (i32, i32) {
|
|||
let mut watchdog = 0; // iterations since something interesting
|
||||
let mut robots = Vec::new();
|
||||
|
||||
let mut craters: Vec<(f32, f32, f32, Color)> = Vec::new();
|
||||
|
||||
let mut score = HashMap::new();
|
||||
|
||||
for i in 5..20 {
|
||||
|
|
@ -198,6 +205,12 @@ async fn run_simulation() -> (i32, i32) {
|
|||
//let rendered = false;
|
||||
clear_background(LIGHTGRAY);
|
||||
|
||||
if rendered {
|
||||
for crater in &craters {
|
||||
draw_circle(crater.0, crater.1, crater.2, Color::new(0.75, 0.75, 0.75, 1.0));
|
||||
}
|
||||
}
|
||||
|
||||
for food in &mut food{
|
||||
if let Some(team) = food.detect(robots.iter()) {
|
||||
if food.living() {
|
||||
|
|
@ -248,7 +261,8 @@ async fn run_simulation() -> (i32, i32) {
|
|||
death = false; // pacifists
|
||||
}
|
||||
if death {
|
||||
if true {robot.draw_weapon();}
|
||||
if rendered {robot.draw_weapon();}
|
||||
craters.push(robot.crater());
|
||||
robot.weapon(peers);
|
||||
}
|
||||
if rendered { robot.draw();}
|
||||
|
|
|
|||
Loading…
Reference in a new issue