1
Fork 0

add permanent weapon marks

This commit is contained in:
Andy Killorin 2026-11-09 17:03:58 -05:00
parent aef4cffd43
commit 0f831acf45
Signed by: ank
GPG key ID: 23F9463ECB67FE8C

View file

@ -84,6 +84,11 @@ impl Robot {
.map(|contact| contact.point1.distance(self.pose.translation)).reduce(|x: f32,y: f32| x.min(y)) .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) { fn draw_weapon(&self) {
let tl = self.pose.translation; let tl = self.pose.translation;
draw_circle(tl.x, tl.y, KILL_RADIUS, ORANGE); 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 watchdog = 0; // iterations since something interesting
let mut robots = Vec::new(); let mut robots = Vec::new();
let mut craters: Vec<(f32, f32, f32, Color)> = Vec::new();
let mut score = HashMap::new(); let mut score = HashMap::new();
for i in 5..20 { for i in 5..20 {
@ -198,6 +205,12 @@ async fn run_simulation() -> (i32, i32) {
//let rendered = false; //let rendered = false;
clear_background(LIGHTGRAY); 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{ for food in &mut food{
if let Some(team) = food.detect(robots.iter()) { if let Some(team) = food.detect(robots.iter()) {
if food.living() { if food.living() {
@ -248,7 +261,8 @@ async fn run_simulation() -> (i32, i32) {
death = false; // pacifists death = false; // pacifists
} }
if death { if death {
if true {robot.draw_weapon();} if rendered {robot.draw_weapon();}
craters.push(robot.crater());
robot.weapon(peers); robot.weapon(peers);
} }
if rendered { robot.draw();} if rendered { robot.draw();}