From 71abee2a1600d11f49d8bbe88ea68339fe533e94 Mon Sep 17 00:00:00 2001 From: onpon4 Date: Fri, 27 Feb 2015 23:14:33 -0500 Subject: [PATCH] Fixed camera jerking in a direction really fast. --- src/player.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/player.cpp b/src/player.cpp index 9e5d0c7..53180ab 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -223,15 +223,13 @@ void doPlayer() cd = player.x - screen->w / 2; if (cd < 0) { - cc = engine.ssx - cameraMaxSpeed; - limitFloat(&cc, cd / 10, -cd / 10); + cc = max(cd / 10, max(0, engine.ssx) - cameraMaxSpeed); player.x -= cc; engine.smx -= cc; } else if (cd > 0) { - cc = cameraMaxSpeed + engine.ssx; - limitFloat(&cc, -cd / 10, cd / 10); + cc = min(cd / 10, cameraMaxSpeed + min(0, engine.ssx)); player.x -= cc; engine.smx -= cc; } @@ -254,15 +252,13 @@ void doPlayer() cd = player.y - screen->h / 2; if (cd < 0) { - cc = engine.ssy - cameraMaxSpeed; - limitFloat(&cc, cd / 10, -cd / 10); + cc = max(cd / 10, max(0, engine.ssy) - cameraMaxSpeed); player.y -= cc; engine.smy -= cc; } else if (cd > 0) { - cc = cameraMaxSpeed + engine.ssy; - limitFloat(&cc, -cd / 10, cd / 10); + cc = min(cd / 10, cameraMaxSpeed + min(0, engine.ssy)); player.y -= cc; engine.smy -= cc; }