X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2FCamera.cpp;h=ad44c0494faf3333ee74b6131277c79b66b21f3d;hb=5f9a1893c0db8f53889a390e4c4b95d57abd4384;hp=d43864ad6d2a44eef942251382c1f56f2f1300ea;hpb=e9bdecf5f58fb9e5b2c067c20d0ce70f54f9ecb7;p=l2e.git diff --git a/src/graphics/Camera.cpp b/src/graphics/Camera.cpp index d43864a..ad44c04 100644 --- a/src/graphics/Camera.cpp +++ b/src/graphics/Camera.cpp @@ -1,34 +1,31 @@ -/* - * Camera.cpp - * - * Created on: Sep 29, 2012 - * Author: holy - */ - #include "Camera.h" #include -using geometry::Vector; +using math::Fixed; +using math::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().Int() - halfWidth) * -1, + (target->Y().Int() - halfHeight) * -1); + } else { + return Vector(); + } } }