Pacman Torben Petré
Loading...
Searching...
No Matches
Camera.h
Go to the documentation of this file.
1#ifndef CAMERA_H
2#define CAMERA_H
3
4
5class Camera {
6public:
10 Camera(Camera &other) = delete;
11 void operator=(const Camera &) = delete;
12
17 [[nodiscard]] static Camera& getInstance();
18
19
29 void setScaling(float mapWidth, float mapHeight);
30
38 void resized();
39
40
46 [[nodiscard]] float xToPixel(float normalizedX) const;
47
53 [[nodiscard]] float yToPixel(float normalizedY) const;
54
55
62 [[nodiscard]] float getTileWidth() const;
63
70 [[nodiscard]] float getTileHeight() const;
71
72private:
73 Camera();
74
75 float screenWidth;
76 float screenHeight;
77
78 float mapWidth;
79 float mapHeight;
80
81 // Mapped to the screen size
82 float tileWidth;
83 float tileHeight;
84
85 // Final dimensions of the world when fit to the screen size
86 float viewWidth;
87 float viewHeight;
88
89 float offsetX;
90 float offsetY;
91};
92
93
94
95#endif //CAMERA_H
void setScaling(float mapWidth, float mapHeight)
Update the Camera scaling factors based on the current world.
Definition Camera.cpp:30
float xToPixel(float normalizedX) const
Definition Camera.cpp:65
float getTileWidth() const
Returns the width of a tile according to the current scaling factors.
Definition Camera.cpp:73
void resized()
Update the Camera scaling factors based on the current window size.
Definition Camera.cpp:52
void operator=(const Camera &)=delete
static Camera & getInstance()
Returns an instance of the Camera class.
Definition Camera.cpp:22
Camera(Camera &other)=delete
float getTileHeight() const
Returns the height of a tile according to the current scaling factors.
Definition Camera.cpp:77
float yToPixel(float normalizedY) const
Definition Camera.cpp:69