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 {
|
||||
// fade trails (doesnt really work)
|
||||
let frame_time = get_frame_time();
|
||||
for x in 0..MAP_WIDTH {
|
||||
for y in 0..MAP_HEIGHT {
|
||||
let mut current_pixel = trail_map.get_pixel(x, y);
|
||||
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);
|
||||
trail_map.bytes.iter_mut().for_each(|b| {
|
||||
if *b > 0 {
|
||||
*b -= 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
// actions
|
||||
ants.iter_mut().for_each(|ant| {
|
||||
ant.walk(frame_time, &mut trail_map);
|
||||
|
|
Loading…
Reference in a new issue