]> git.localhorst.tv Git - space.git/blob - src/graphics/Camera.cpp
ad2587f3e755e5a06b5fc47300da564ee4a426fe
[space.git] / src / graphics / Camera.cpp
1 #include "Camera.h"
2
3
4 namespace space {
5
6 Camera::Camera(int w, int h, const Vector<float> &t)
7 : target(&t)
8 , offset(w/2, h/2)
9 , zoom(1)
10 , zoomAcc(0) {
11
12 }
13
14
15 void Camera::Resize(int w, int h) {
16         offset = Vector<float>(w/2, h/2);
17 }
18
19 void Camera::Update(float delta) {
20         zoom += zoom * zoomAcc * delta;
21         if (zoom < 0.0001) zoom = 0.0001;
22 }
23
24 void Camera::StartZoom() {
25         zoomAcc += 1;
26 }
27
28 void Camera::StopZoom() {
29         zoomAcc -= 1;
30 }
31
32 void Camera::StartShrink() {
33         zoomAcc -= 1;
34 }
35
36 void Camera::StopShrink() {
37         zoomAcc += 1;
38 }
39
40 }