From 23f0feaae00301fc99b7b1de179991f5f5b17c27 Mon Sep 17 00:00:00 2001 From: Alula <6276139+alula@users.noreply.github.com> Date: Sat, 16 Oct 2021 15:26:10 +0200 Subject: [PATCH] fix cs+switch scrolling --- src/frame.rs | 5 +++-- src/scene/game_scene.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/frame.rs b/src/frame.rs index 1c1aad6..7cba8a2 100644 --- a/src/frame.rs +++ b/src/frame.rs @@ -36,7 +36,7 @@ impl Frame { pub fn immediate_update(&mut self, state: &mut SharedGameState, stage: &Stage) { let mut screen_width = state.canvas_size.0; - if state.constants.is_switch { + if state.constants.is_switch && stage.map.width <= 54 { screen_width += 10.0; // hack for scrolling } @@ -78,9 +78,10 @@ impl Frame { pub fn update(&mut self, state: &mut SharedGameState, stage: &Stage) { let mut screen_width = state.canvas_size.0; - if state.constants.is_switch { + if state.constants.is_switch && stage.map.width <= 54 { screen_width += 10.0; } + let tile_size = state.tile_size.as_int(); if (stage.map.width as usize).saturating_sub(1) * (tile_size as usize) < screen_width as usize { diff --git a/src/scene/game_scene.rs b/src/scene/game_scene.rs index d2ee6a3..648da00 100644 --- a/src/scene/game_scene.rs +++ b/src/scene/game_scene.rs @@ -398,7 +398,7 @@ impl GameScene { for y in 0..(state.canvas_size.1 as i32 / 16 + 1) { if direction == FadeDirection::Left { - batch.add_rect(state.canvas_size.0 - x as f32 * 16.0, y as f32 * 16.0, &rect); + batch.add_rect(state.canvas_size.0 - x as f32 * 16.0 - 16.0, y as f32 * 16.0, &rect); } else { batch.add_rect(x as f32 * 16.0, y as f32 * 16.0, &rect); }