From bc382a4985a97428c78807653b3c011670700a4c Mon Sep 17 00:00:00 2001 From: Misa Date: Sun, 28 Mar 2021 12:53:08 -0700 Subject: [PATCH] Fix tower camera invincibility inconsistencies If you have invincibility enabled, the tower camera behavior is inconsistent. In ascending towers, you can "push" the camera upwards; however you cannot push it downwards; at least it stays still when it comes up to you if you stay still. In descending towers, the camera moves quicker when you're at the bottom of the screen, but it's slower than your falling speed and quickly loses sight of you; the camera can be pushed upwards; unfortunately it also does a "bumping" motion if you're standing still when the camera reaches you, which gets real annoying and isn't particularly pleasant to look at. There are two problems, so this does two fixes: 1. Pushing the camera now applies the appropriate counter-offset depending on the direction of the tower. You can now push the camera downwards in ascending towers. 2. To fix the "bumping" when the camera reaches you if you stand still, there are now a 8-pixel-high "gray areas" at the top and bottom of the screen where the camera simply won't move if you're in them. Doing these camera offsets instead of simply canceling the movement if the player is offscreen is a bit ugly... but it works for now. --- desktop_version/src/Logic.cpp | 46 +++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/desktop_version/src/Logic.cpp b/desktop_version/src/Logic.cpp index 2a37bccc..76064ccd 100644 --- a/desktop_version/src/Logic.cpp +++ b/desktop_version/src/Logic.cpp @@ -892,11 +892,53 @@ void gamelogic(void) if (above_screen) { - map.ypos-=10; + if (obj.entities[player].yp - map.ypos <= 0) + { + if (graphics.towerbg.scrolldir == 1) + { + /* Descending tower: + * Counteract 10 pixels of terminal velocity + * + 2 pixels of camera movement */ + map.ypos -= 12; + } + else + { + /* Ascending tower: + * Move 8 out of 10 pixels of terminal velocity + * Camera movement will move 2 pixels for us */ + map.ypos -= 8; + } + } + else + { + /* Counter 2 pixels of camera movement */ + map.ypos -= 2; + } } else if (below_screen) { - map.ypos+=2; + if (obj.entities[player].yp - map.ypos >= 208) + { + if (graphics.towerbg.scrolldir == 0) + { + /* Ascending tower: + * Counteract 10 pixels of terminal velocity + * + 2 pixels of camera movement */ + map.ypos += 12; + } + else + { + /* Descending tower: + * Move 8 out of 10 pixels of terminal velocity + * Camera movement will move 2 pixels for us */ + map.ypos += 8; + } + } + else + { + /* Counter 2 pixels of camera movement */ + map.ypos += 2; + } } if (above_screen || below_screen)