]> git.localhorst.tv Git - l2e.git/blobdiff - src/graphics/Camera.cpp
switched geometric scalars from floating to fixed
[l2e.git] / src / graphics / Camera.cpp
index a0773db821ca1a14a0ec6fafa066f7533cda8d1a..ad44c0494faf3333ee74b6131277c79b66b21f3d 100644 (file)
@@ -1,34 +1,31 @@
-/*
- * Camera.cpp
- *
- *  Created on: Sep 29, 2012
- *      Author: holy
- */
-
 #include "Camera.h"
 
 #include <cassert>
 
-using geometry::Vector;
+using math::Fixed;
+using math::Vector;
 
 namespace graphics {
 
-Camera::Camera(int width, int height, const Vector<float> *target)
+Camera::Camera(int width, int height, const Vector<Fixed<8> > *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");
+void Camera::SetTarget(const Vector<Fixed<8> > *t) {
        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().Int() - halfWidth) * -1,
+                               (target->Y().Int() - halfHeight) * -1);
+       } else {
+               return Vector<int>();
+       }
 }
 
 }