Player icon indicating copy to clipboard operation
Player copied to clipboard

Shake screen moves viewport in wrong direction

Open carstene1ns opened this issue 3 years ago • 1 comments

Issue mentioned in forums, tested in continuous build on Windows and Linux, I made a testcase (attached).

screenshot

shake-bug.zip

RPG_RT moves right, Player left.

carstene1ns avatar Jul 16 '22 15:07 carstene1ns

proposed fix:

diff --git a/src/shake.h b/src/shake.h
index 2e29c4839..7880ce4fb 100644
--- a/src/shake.h
+++ b/src/shake.h
@@ -35,7 +35,7 @@ static constexpr int kShakeContinuousTimeStart = 65535;
  */
 inline int NextPosition(int strength, int speed, int time_left, int position) {
 	int amplitude = 1 + 2 * strength;
-	int newpos = amplitude * sin((time_left * 4 * (speed + 2)) % 256 * M_PI / 128);
+	int newpos = amplitude * sin((time_left * 4 * (speed + 2)) % 256 * M_PI / 128) * -1;
 	int cutoff = (speed * amplitude / 8) + 1;
 
 	return Utils::Clamp<int>(newpos, position - cutoff, position + cutoff);

carstene1ns avatar Sep 03 '22 11:09 carstene1ns

thanks. will pick this one into #2860 later

Ghabry avatar Nov 23 '22 13:11 Ghabry