]> git.localhorst.tv Git - l2e.git/blob - src/graphics/Camera.cpp
fix blocking flag of guy
[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         assert(target && "construct camera without target");
19 }
20
21
22 void Camera::SetTarget(const Vector<float> *t) {
23         assert(t && "cannot change camera target to 0");
24         target = t;
25 }
26
27
28 Vector<int> Camera::CalculateOffset() const {
29         return Vector<int>(
30                         (target->X() - halfWidth) * -1,
31                         (target->Y() - halfHeight) * -1);
32 }
33
34 }