From 5c3fbd0022164133c6486799348af519597472b4 Mon Sep 17 00:00:00 2001 From: Misa Date: Sun, 28 Mar 2021 12:53:08 -0700 Subject: [PATCH] Fix background smearing pushing tower camera with invincibility If you have invincibility enabled and push the camera, the background would smear. This is because the game doesn't calculate the proper bscroll and bypos of the tower background, and also doesn't end up redrawing it. We do both these things now, so this is fixed. --- desktop_version/src/Logic.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/desktop_version/src/Logic.cpp b/desktop_version/src/Logic.cpp index e01885f0..6d2f2916 100644 --- a/desktop_version/src/Logic.cpp +++ b/desktop_version/src/Logic.cpp @@ -896,17 +896,25 @@ void gamelogic(void) } else if (INBOUNDS_VEC(player, obj.entities)) { - if (obj.entities[player].yp-map.ypos <= 0) + const bool above_screen = obj.entities[player].yp-map.ypos <= 8; + const bool below_screen = obj.entities[player].yp-map.ypos >= 200; + + if (above_screen) { map.ypos-=10; - graphics.towerbg.bypos = map.ypos / 2; - graphics.towerbg.bscroll = 0; } - else if (obj.entities[player].yp-map.ypos >= 208) + else if (below_screen) { map.ypos+=2; + } + + if (above_screen || below_screen) + { graphics.towerbg.bypos = map.ypos / 2; - graphics.towerbg.bscroll = 0; + graphics.towerbg.bscroll = (map.ypos - map.oldypos) / 2; + + /* The buffer isn't big enough; we have to redraw */ + graphics.towerbg.tdrawback = true; } }