]> git.localhorst.tv Git - l2e.git/blob - Camera.cpp
ad44c0494faf3333ee74b6131277c79b66b21f3d
[l2e.git] / 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 }