X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2FCamera.cpp;h=6039586ffb7eca0caa7be2703753b977ea9f54a1;hb=cc3d698b8c1ad09d7a3f9e3f28bc84e0ac1735ea;hp=a0773db821ca1a14a0ec6fafa066f7533cda8d1a;hpb=b8790ff84da07774a2eb986ca6b9379a16a8ea7b;p=l2e.git diff --git a/src/graphics/Camera.cpp b/src/graphics/Camera.cpp index a0773db..6039586 100644 --- a/src/graphics/Camera.cpp +++ b/src/graphics/Camera.cpp @@ -1,10 +1,3 @@ -/* - * Camera.cpp - * - * Created on: Sep 29, 2012 - * Author: holy - */ - #include "Camera.h" #include @@ -15,20 +8,23 @@ namespace graphics { Camera::Camera(int width, int height, const Vector *target) : target(target), halfWidth(width / 2), halfHeight(height / 2) { - assert(target && "construct camera without target"); + } void Camera::SetTarget(const Vector *t) { - assert(t && "cannot change camera target to 0"); target = t; } Vector Camera::CalculateOffset() const { - return Vector( - (target->X() - halfWidth) * -1, - (target->Y() - halfHeight) * -1); + if (target) { + return Vector( + (target->X() - halfWidth) * -1, + (target->Y() - halfHeight) * -1); + } else { + return Vector(); + } } }