X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2FCamera.cpp;h=e882eb19a322f32231f501d286f24109edb397fd;hb=978ccdf2644bc445c864dbe581ead365b238cff8;hp=d43864ad6d2a44eef942251382c1f56f2f1300ea;hpb=e9bdecf5f58fb9e5b2c067c20d0ce70f54f9ecb7;p=l2e.git diff --git a/src/graphics/Camera.cpp b/src/graphics/Camera.cpp index d43864a..e882eb1 100644 --- a/src/graphics/Camera.cpp +++ b/src/graphics/Camera.cpp @@ -13,22 +13,25 @@ using geometry::Vector; namespace graphics { -Camera::Camera(int width, int height, const Vector *target) +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"); +void Camera::SetTarget(const Vector *t) { 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(); + } } }