From 7d62e80ca081e343934f75c5bca52ce0a75ef795 Mon Sep 17 00:00:00 2001 From: Juliano Leal Goncalves Date: Sun, 27 Jun 2021 18:47:27 -0300 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Replace=20'tileShiftX'=20a?= =?UTF-8?q?nd=20'tileShiftY'=20globals=20with=20single=20'tileShift'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/scrollrt.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index b3471f18c..68906cdd3 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -1106,8 +1106,7 @@ void Zoom(const Surface &out) int tileOffsetX; int tileOffsetY; -int tileShiftX; -int tileShiftY; +Displacement tileShift; int tileColums; int tileRows; @@ -1134,7 +1133,7 @@ void DrawGame(const Surface &fullOut, Point position) int columns = tileColums; int rows = tileRows; - position += Displacement { tileShiftX, tileShiftY }; + position += tileShift; // Skip rendering parts covered by the panels if (CanPanelsCoverView()) { @@ -1549,8 +1548,7 @@ void TilesInView(int *rcolumns, int *rrows) void CalcViewportGeometry() { - tileShiftX = 0; - tileShiftY = 0; + tileShift = { 0, 0 }; // Adjust by player offset and tile grid alignment int xo = 0; @@ -1563,13 +1561,13 @@ void CalcViewportGeometry() int lrow = tileRows - RowsCoveredByPanel(); // Center player tile on screen - ShiftGrid(&tileShiftX, &tileShiftY, -tileColums / 2, -lrow / 2); + ShiftGrid(&tileShift.deltaX, &tileShift.deltaY, -tileColums / 2, -lrow / 2); tileRows *= 2; // Align grid if ((tileColums & 1) == 0) { - tileShiftY--; // Shift player row to one that can be centered with out pixel offset + tileShift.deltaY--; // Shift player row to one that can be centered with out pixel offset if ((lrow & 1) == 0) { // Offset tile to vertically align the player when both rows and colums are even tileRows++; @@ -1577,7 +1575,7 @@ void CalcViewportGeometry() } } else if ((tileColums & 1) != 0 && (lrow & 1) != 0) { // Offset tile to vertically align the player when both rows and colums are odd - ShiftGrid(&tileShiftX, &tileShiftY, 0, -1); + ShiftGrid(&tileShift.deltaX, &tileShift.deltaY, 0, -1); tileRows++; tileOffsetY -= TILE_HEIGHT / 2; }