Fixed camera jerking in a direction really fast.

This commit is contained in:
onpon4 2015-02-27 23:14:33 -05:00
parent 9a910cfdfd
commit 71abee2a16
1 changed files with 4 additions and 8 deletions

View File

@ -223,15 +223,13 @@ void doPlayer()
cd = player.x - screen->w / 2; cd = player.x - screen->w / 2;
if (cd < 0) if (cd < 0)
{ {
cc = engine.ssx - cameraMaxSpeed; cc = max(cd / 10, max(0, engine.ssx) - cameraMaxSpeed);
limitFloat(&cc, cd / 10, -cd / 10);
player.x -= cc; player.x -= cc;
engine.smx -= cc; engine.smx -= cc;
} }
else if (cd > 0) else if (cd > 0)
{ {
cc = cameraMaxSpeed + engine.ssx; cc = min(cd / 10, cameraMaxSpeed + min(0, engine.ssx));
limitFloat(&cc, -cd / 10, cd / 10);
player.x -= cc; player.x -= cc;
engine.smx -= cc; engine.smx -= cc;
} }
@ -254,15 +252,13 @@ void doPlayer()
cd = player.y - screen->h / 2; cd = player.y - screen->h / 2;
if (cd < 0) if (cd < 0)
{ {
cc = engine.ssy - cameraMaxSpeed; cc = max(cd / 10, max(0, engine.ssy) - cameraMaxSpeed);
limitFloat(&cc, cd / 10, -cd / 10);
player.y -= cc; player.y -= cc;
engine.smy -= cc; engine.smy -= cc;
} }
else if (cd > 0) else if (cd > 0)
{ {
cc = cameraMaxSpeed + engine.ssy; cc = min(cd / 10, cameraMaxSpeed + min(0, engine.ssy));
limitFloat(&cc, -cd / 10, cd / 10);
player.y -= cc; player.y -= cc;
engine.smy -= cc; engine.smy -= cc;
} }