From 011f533449c31a5488afd2f577b21d90177abef2 Mon Sep 17 00:00:00 2001 From: Tool Man Date: Sat, 23 Nov 2024 14:32:56 -0500 Subject: [PATCH] Add support for .relative & .centered When using .relative & .centered tags for PixelScrolling, do the following: - Get half the width/height of the screen - Move screen by ( h/v - screen_width/height ) divided by two. When compared to Maniacs Patch 240822, it works as expected. Tested using different resolutions, works like it should. --- src/game_player.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/game_player.cpp b/src/game_player.cpp index 0650ed366f..4afc557ea5 100644 --- a/src/game_player.cpp +++ b/src/game_player.cpp @@ -811,8 +811,12 @@ void Game_Player::StartPixelPan(int h, int v, int speed, bool interpolated, bool int new_pan_x; int new_pan_y; - // FIXME: Fails when relative and centered are used in combination - if (relative) { + if (relative && centered) { + int screen_width = static_cast(std::ceil(static_cast(Player::screen_width) / 2)) * TILE_SIZE; + int screen_height = static_cast(std::ceil(static_cast(Player::screen_height) / 2)) * TILE_SIZE; + new_pan_x = data()->pan_finish_x - (h - screen_width) * 0.5; + new_pan_y = data()->pan_finish_y - (v - screen_height) * 0.5; + } else if (relative) { new_pan_x = data()->pan_finish_x - h; new_pan_y = data()->pan_finish_y - v; } else if (centered) {