-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCamera.cpp
More file actions
49 lines (39 loc) · 740 Bytes
/
Camera.cpp
File metadata and controls
49 lines (39 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "Camera.h"
#include "Actor.h"
#include <SFML/Graphics.hpp>
Camera::Camera(): m_currentView(sf::FloatRect(0.f, 0.f, 0.f, 0.f)), m_zoomLevel(1.0f)
{
};
Camera::Camera(sf::Vector2i): m_currentView(sf::FloatRect(0.f, 0.f, 0.f, 0.f)), m_zoomLevel(1.0f)
{
};
sf::View Camera::getView()
{
return m_currentView;
}
void Camera::setWinScale(float x, float y)
{
m_currentView.setSize(x*(1/m_zoomLevel), y*(1/m_zoomLevel));
}
void Camera::move(sf::Vector2f movement)
{
m_currentView.move(movement);
}
float Camera::getZoom()
{
return m_zoomLevel;
}
void Camera::setZoom(float zoom)
{
if(zoom>=0.f)
{
m_zoomLevel=zoom;
}
}
void Camera::zoom(float zoom)
{
if(m_zoomLevel+zoom>=0.f)
{
m_zoomLevel+=zoom;
}
}