From 5384a7afe4cb587013e457055f221ce5e1fb70e5 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Sun, 23 Oct 2022 15:37:45 +0100 Subject: [PATCH] Fixed a scrolled screen snapping back to centre on the player as soon as they move --- Data/Scripts/004_Game classes/009_Game_Player.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Data/Scripts/004_Game classes/009_Game_Player.rb b/Data/Scripts/004_Game classes/009_Game_Player.rb index 862416ea7..7ed090440 100644 --- a/Data/Scripts/004_Game classes/009_Game_Player.rb +++ b/Data/Scripts/004_Game classes/009_Game_Player.rb @@ -529,11 +529,17 @@ class Game_Player < Game_Character end end - # Center player on-screen + # Track the player on-screen as they move def update_screen_position(last_real_x, last_real_y) return if self.map.scrolling? || !(@moved_last_frame || @moved_this_frame) - self.map.display_x = @real_x - SCREEN_CENTER_X - self.map.display_y = @real_y - SCREEN_CENTER_Y + if (@real_x < last_real_x && @real_x - $game_map.display_x < SCREEN_CENTER_X) || + (@real_x > last_real_x && @real_x - $game_map.display_x > SCREEN_CENTER_X) + self.map.display_x += @real_x - last_real_x + end + if (@real_y < last_real_y && @real_y - $game_map.display_y < SCREEN_CENTER_Y) || + (@real_y > last_real_y && @real_y - $game_map.display_y > SCREEN_CENTER_Y) + self.map.display_y += @real_y - last_real_y + end end def update_event_triggering