]> git.localhorst.tv Git - l2e.git/blob - src/graphics/Camera.cpp
e882eb19a322f32231f501d286f24109edb397fd
[l2e.git] / src / graphics / Camera.cpp
1 /*
2  * Camera.cpp
3  *
4  *  Created on: Sep 29, 2012
5  *      Author: holy
6  */
7
8 #include "Camera.h"
9
10 #include <cassert>
11
12 using geometry::Vector;
13
14 namespace graphics {
15
16 Camera::Camera(int width, int height, const Vector<float> *target)
17 : target(target), halfWidth(width / 2), halfHeight(height / 2) {
18
19 }
20
21
22 void Camera::SetTarget(const Vector<float> *t) {
23         target = t;
24 }
25
26
27 Vector<int> Camera::CalculateOffset() const {
28         if (target) {
29                 return Vector<int>(
30                                 (target->X() - halfWidth) * -1,
31                                 (target->Y() - halfHeight) * -1);
32         } else {
33                 return Vector<int>();
34         }
35 }
36
37 }