Skip to content

Commit d9dd9be

Browse files
authored
Merge pull request #3302 from ToolMan2k/PixelScrolling
Maniacs Feature - Add .relative & .centered support on PixelPanScreen
2 parents 24c5fa6 + 011f533 commit d9dd9be

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/game_player.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -811,8 +811,12 @@ void Game_Player::StartPixelPan(int h, int v, int speed, bool interpolated, bool
811811
int new_pan_x;
812812
int new_pan_y;
813813

814-
// FIXME: Fails when relative and centered are used in combination
815-
if (relative) {
814+
if (relative && centered) {
815+
int screen_width = static_cast<int>(std::ceil(static_cast<float>(Player::screen_width) / 2)) * TILE_SIZE;
816+
int screen_height = static_cast<int>(std::ceil(static_cast<float>(Player::screen_height) / 2)) * TILE_SIZE;
817+
new_pan_x = data()->pan_finish_x - (h - screen_width) * 0.5;
818+
new_pan_y = data()->pan_finish_y - (v - screen_height) * 0.5;
819+
} else if (relative) {
816820
new_pan_x = data()->pan_finish_x - h;
817821
new_pan_y = data()->pan_finish_y - v;
818822
} else if (centered) {

0 commit comments

Comments
 (0)