From 918173fb841e9617648ee5537c3b40bb637980e2 Mon Sep 17 00:00:00 2001 From: Azalea Gui Date: Thu, 9 Mar 2023 01:37:13 -0500 Subject: [PATCH] [+] Render snow with fractional scrolling --- tngame-rs/src/main.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tngame-rs/src/main.rs b/tngame-rs/src/main.rs index ace064b..46c5ffe 100644 --- a/tngame-rs/src/main.rs +++ b/tngame-rs/src/main.rs @@ -226,6 +226,8 @@ impl Mutes { /// Update snow particles fn update_snow(&mut self, dt: f32) { + let scroll = self.get_scroll(); + // Loop through all snow particles for p in &mut self.snow { // Update the snow particle position @@ -251,7 +253,7 @@ impl Mutes { let x = p.x.round() as i32; let y = p.y.round() as i32; if x < self.w && y < self.h { - self.buf[y as usize][x as usize] = Some(Pixel { color: p.color, char: '*' }); + self.buf[y as usize][(x + self.w - scroll / 2).rem_euclid(self.w) as usize] = Some(Pixel { color: p.color, char: '*' }); } } }