From 6cfe247b362106543bbb1a835dde9e7da9128fee Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 19 Mar 2022 10:09:14 -0400 Subject: fixed jitter while moving and zooming --- src/game.cpp | 2 -- src/game.h | 3 --- src/renderer.cpp | 12 ++++++------ 3 files changed, 6 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/game.cpp b/src/game.cpp index 31c682c..f048400 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -613,8 +613,6 @@ void Game::setZoom(size_t zoom) return; } - /*zoomProgress = 0; - zoomLength = std::abs(static_cast(zoom - curZoom)) * TILE_WIDTH;*/ zoomProgress.start(62 * std::abs(static_cast(zoom) - curZoom) * TILE_WIDTH); oldZoom = curZoom; curZoom = zoom; diff --git a/src/game.h b/src/game.h index 0c4c89f..a70f57e 100644 --- a/src/game.h +++ b/src/game.h @@ -86,8 +86,6 @@ public: int curZoom = INIT_ZOOM; int oldZoom = INIT_ZOOM; bool zooming = false; - //int zoomProgress = 0; - //int zoomLength; Interpolation zoomProgress; double getZoomBasis() const { return zooming ? std::max(curZoom, oldZoom) : curZoom; } @@ -105,7 +103,6 @@ public: Timer inputTimer = {50}; Timer losePopLampTimer = {800}; Timer losePopPlayerTimer = {3000}; - //Timer zoomTimer = {62}; std::vector signTexts; int nextSignIndex = 0; diff --git a/src/renderer.cpp b/src/renderer.cpp index 94be197..b90372e 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -370,19 +370,19 @@ void Renderer::renderGame( if (game.moving) { if (game.player_x > game.player_oldx) { - oldRect.x += game.moveProgress.getProgress(0, TILE_WIDTH); - zoomRect.x += game.moveProgress.getProgress(0, TILE_WIDTH); - } else if (game.player_x < game.player_oldx) { oldRect.x -= game.moveProgress.getProgress(TILE_WIDTH, 0); zoomRect.x -= game.moveProgress.getProgress(TILE_WIDTH, 0); + } else if (game.player_x < game.player_oldx) { + oldRect.x += game.moveProgress.getProgress(TILE_WIDTH, 0); + zoomRect.x += game.moveProgress.getProgress(TILE_WIDTH, 0); } if (game.player_y > game.player_oldy) { - oldRect.y += game.moveProgress.getProgress(0, TILE_HEIGHT); - zoomRect.y += game.moveProgress.getProgress(0, TILE_HEIGHT); - } else if (game.player_y < game.player_oldy) { oldRect.y -= game.moveProgress.getProgress(TILE_HEIGHT, 0); zoomRect.y -= game.moveProgress.getProgress(TILE_HEIGHT, 0); + } else if (game.player_y < game.player_oldy) { + oldRect.y += game.moveProgress.getProgress(TILE_HEIGHT, 0); + zoomRect.y += game.moveProgress.getProgress(TILE_HEIGHT, 0); } } -- cgit 1.4.1