From fe1045b5153d182db0bcd3a535ec17e61f6da966 Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 30 Apr 2020 11:52:21 -0700 Subject: [PATCH] Interpolate tower scrolling Now tower scrolling will look smooth ayy-eff. --- desktop_version/src/Graphics.cpp | 12 +++++++----- desktop_version/src/Logic.cpp | 1 + desktop_version/src/Map.cpp | 4 ++++ desktop_version/src/Map.h | 1 + 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index e33b73e2..8ddbe85d 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -1481,7 +1481,7 @@ void Graphics::drawentities() int yoff; if (map.towermode) { - yoff = map.ypos; + yoff = lerp(map.oldypos, map.ypos); } else { @@ -2320,12 +2320,13 @@ void Graphics::drawfinalmap() void Graphics::drawtowermap() { int temp; + int yoff = lerp(map.oldypos, map.ypos); for (int j = 0; j < 31; j++) { for (int i = 0; i < 40; i++) { - temp = map.tower.at(i, j, map.ypos); - if (temp > 0) drawtile3(i * 8, (j * 8) - ((int)map.ypos % 8), temp, map.colstate); + temp = map.tower.at(i, j, yoff); + if (temp > 0) drawtile3(i * 8, (j * 8) - (yoff % 8), temp, map.colstate); } } } @@ -2333,12 +2334,13 @@ void Graphics::drawtowermap() void Graphics::drawtowermap_nobackground() { int temp; + int yoff = lerp(map.oldypos, map.ypos); for (int j = 0; j < 31; j++) { for (int i = 0; i < 40; i++) { - temp = map.tower.at(i, j, map.ypos); - if (temp > 0 && temp<28) drawtile3(i * 8, (j * 8) - ((int)map.ypos % 8), temp, map.colstate); + temp = map.tower.at(i, j, yoff); + if (temp > 0 && temp<28) drawtile3(i * 8, (j * 8) - (yoff % 8), temp, map.colstate); } } } diff --git a/desktop_version/src/Logic.cpp b/desktop_version/src/Logic.cpp index 51027881..8bed0f9b 100644 --- a/desktop_version/src/Logic.cpp +++ b/desktop_version/src/Logic.cpp @@ -260,6 +260,7 @@ void gamelogic() if (map.towermode) { + map.oldypos = map.ypos; if(!game.completestop) { if (map.cameramode == 0) diff --git a/desktop_version/src/Map.cpp b/desktop_version/src/Map.cpp index 199d22f6..e24d8042 100644 --- a/desktop_version/src/Map.cpp +++ b/desktop_version/src/Map.cpp @@ -91,6 +91,10 @@ mapclass::mapclass() 2,2,2,2,2,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0, }; areamap.insert(areamap.end(), tmap, tmap+400); + + ypos = 0; + oldypos = 0; + bypos = 0; } int mapclass::RGB(int red,int green,int blue) diff --git a/desktop_version/src/Map.h b/desktop_version/src/Map.h index 18c2d032..ac276e17 100644 --- a/desktop_version/src/Map.h +++ b/desktop_version/src/Map.h @@ -98,6 +98,7 @@ public: //Special tower stuff bool towermode; float ypos; + float oldypos; int bypos; int cameramode; int cameraseek, cameraseekframe;