+/*
+ * Camera.cpp
+ *
+ * Created on: Sep 29, 2012
+ * Author: holy
+ */
+
+#include "Camera.h"
+
+#include <cassert>
+
+using geometry::Vector;
+
+namespace graphics {
+
+Camera::Camera(int width, int height, const Vector<int> *target)
+: target(target), halfWidth(width / 2), halfHeight(height / 2) {
+ assert(target && "construct camera without target");
+}
+
+
+void Camera::SetTarget(const Vector<int> *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);
+}
+
+}