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