optimize fading of trails
This commit is contained in:
parent
8b49ae2792
commit
4b176baabf
1 changed files with 4 additions and 8 deletions
12
src/main.rs
12
src/main.rs
|
@ -26,15 +26,11 @@ async fn main() {
|
||||||
loop {
|
loop {
|
||||||
// fade trails (doesnt really work)
|
// fade trails (doesnt really work)
|
||||||
let frame_time = get_frame_time();
|
let frame_time = get_frame_time();
|
||||||
for x in 0..MAP_WIDTH {
|
trail_map.bytes.iter_mut().for_each(|b| {
|
||||||
for y in 0..MAP_HEIGHT {
|
if *b > 0 {
|
||||||
let mut current_pixel = trail_map.get_pixel(x, y);
|
*b -= 1;
|
||||||
current_pixel.r -= 0.1 * frame_time;
|
|
||||||
current_pixel.g -= 0.1 * frame_time;
|
|
||||||
current_pixel.b -= 0.1 * frame_time;
|
|
||||||
trail_map.set_pixel(x, y, current_pixel);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
// actions
|
// actions
|
||||||
ants.iter_mut().for_each(|ant| {
|
ants.iter_mut().for_each(|ant| {
|
||||||
ant.walk(frame_time, &mut trail_map);
|
ant.walk(frame_time, &mut trail_map);
|
||||||
|
|
Loading…
Reference in a new issue