-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcamera.hh
More file actions
32 lines (23 loc) · 886 Bytes
/
Copy pathcamera.hh
File metadata and controls
32 lines (23 loc) · 886 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
#ifndef _GRAVITY_CAMERA_HH_
#define _GRAVITY_CAMERA_HH_
#include <box2d/box2d.h>
#include <SDL2/SDL.h>
struct Camera {
Camera();
/// The bottom-left position of the camera.
b2Vec2 pos;
/// Pixels-per-meter
float ppm;
/// Convert the given point in world coordinates to screen
/// coordinate seen in this camera. The `x` and `y` parameters will
/// hold the converted coordinates upon return.
void PointToScreen(SDL_Window *window, b2Vec2 p, int &x, int &y) const;
/// Convert the given length in world units to pixels seen by this
/// camera.
float LengthToScreen(float length) const;
/// Convert the given point (x, y) on screen to world coordinates.
b2Vec2 PointToWorld(int x, int y, SDL_Window *window) const;
/// Convert the given length in pixels to world units.
float LengthToWorld(float length) const;
};
#endif /* _GRAVITY_CAMERA_HH_ */