From 5965f44bb11e265024ed3db76d546196d99188c0 Mon Sep 17 00:00:00 2001 From: onpon4 Date: Fri, 27 Feb 2015 01:10:27 -0500 Subject: [PATCH] Made camera centering more gentle. --- src/player.cpp | 52 ++++++++++++-------------------------------------- 1 file changed, 12 insertions(+), 40 deletions(-) diff --git a/src/player.cpp b/src/player.cpp index 4b3c78a..864d6fe 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -220,30 +220,16 @@ void doPlayer() if (cd < 0) { cc = engine.ssx - cameraMaxSpeed; - if (cd < cc) - { - player.x -= cc; - engine.smx -= cc; - } - else - { - player.x -= cd; - engine.smx -= cd; - } + limitFloat(&cc, cd / 10, -cd / 10); + player.x -= cc; + engine.smx -= cc; } else if (cd > 0) { cc = cameraMaxSpeed + engine.ssx; - if (cd > cc) - { - player.x -= cc; - engine.smx -= cc; - } - else - { - player.x -= cd; - engine.smx -= cd; - } + limitFloat(&cc, -cd / 10, cd / 10); + player.x -= cc; + engine.smx -= cc; } } if (ymoved) @@ -265,30 +251,16 @@ void doPlayer() if (cd < 0) { cc = engine.ssy - cameraMaxSpeed; - if (cd < cc) - { - player.y -= cc; - engine.smy -= cc; - } - else - { - player.y -= cd; - engine.smy -= cd; - } + limitFloat(&cc, cd / 10, -cd / 10); + player.y -= cc; + engine.smy -= cc; } else if (cd > 0) { cc = cameraMaxSpeed + engine.ssy; - if (cd > cc) - { - player.y -= cc; - engine.smy -= cc; - } - else - { - player.y -= cd; - engine.smy -= cd; - } + limitFloat(&cc, -cd / 10, cd / 10); + player.y -= cc; + engine.smy -= cc; } } }