]> git.localhorst.tv Git - l2e.git/blob - src/graphics/Camera.cpp
removed stupid file headers that eclipse put in
[l2e.git] / src / graphics / Camera.cpp
1 #include "Camera.h"
2
3 #include <cassert>
4
5 using geometry::Vector;
6
7 namespace graphics {
8
9 Camera::Camera(int width, int height, const Vector<float> *target)
10 : target(target), halfWidth(width / 2), halfHeight(height / 2) {
11
12 }
13
14
15 void Camera::SetTarget(const Vector<float> *t) {
16         target = t;
17 }
18
19
20 Vector<int> Camera::CalculateOffset() const {
21         if (target) {
22                 return Vector<int>(
23                                 (target->X() - halfWidth) * -1,
24                                 (target->Y() - halfHeight) * -1);
25         } else {
26                 return Vector<int>();
27         }
28 }
29
30 }