]> git.localhorst.tv Git - l2e.git/blobdiff - src/graphics/Camera.cpp
made targetless camera possible
[l2e.git] / src / graphics / Camera.cpp
index a0773db821ca1a14a0ec6fafa066f7533cda8d1a..e882eb19a322f32231f501d286f24109edb397fd 100644 (file)
@@ -15,20 +15,23 @@ namespace graphics {
 
 Camera::Camera(int width, int height, const Vector<float> *target)
 : target(target), halfWidth(width / 2), halfHeight(height / 2) {
-       assert(target && "construct camera without target");
+
 }
 
 
 void Camera::SetTarget(const Vector<float> *t) {
-       assert(t && "cannot change camera target to 0");
        target = t;
 }
 
 
 Vector<int> Camera::CalculateOffset() const {
-       return Vector<int>(
-                       (target->X() - halfWidth) * -1,
-                       (target->Y() - halfHeight) * -1);
+       if (target) {
+               return Vector<int>(
+                               (target->X() - halfWidth) * -1,
+                               (target->Y() - halfHeight) * -1);
+       } else {
+               return Vector<int>();
+       }
 }
 
 }