raylib-cpp
C++ object-oriented wrapper library for raylib.
Camera2D.hpp
1 #ifndef RAYLIB_CPP_CAMERA_HPP_
2 #define RAYLIB_CPP_CAMERA_HPP_
3 
4 #ifdef __cplusplus
5 extern "C"{
6 #endif
7 #include "raylib.h"
8 #ifdef __cplusplus
9 }
10 #endif
11 
12 #include "./Vector2.hpp"
13 #include "./raylib-cpp-utils.hpp"
14 
15 namespace raylib {
16  class Camera2D : public ::Camera2D {
17  public:
18  Camera2D(::Vector2 offsetValue, ::Vector2 targetValue, float rotationValue = 0, float zoomValue = 1) {
19  offset = offsetValue;
20  target = targetValue;
21  rotation = rotationValue;
22  zoom = zoomValue;
23  };
24 
25  inline void set(const ::Camera2D& camera) {
26  offset = camera.offset;
27  target = camera.target;
28  rotation = camera.rotation;
29  zoom = camera.zoom;
30  }
31 
32  inline void set(const Camera2D& camera) {
33  offset = camera.offset;
34  target = camera.target;
35  rotation = camera.rotation;
36  zoom = camera.zoom;
37  }
38 
39  inline Camera2D& BeginMode2D() {
40  ::BeginMode2D(*this);
41  return *this;
42  }
43  inline Camera2D& EndMode2D() {
44  ::EndMode2D();
45  return *this;
46  }
47 
48  GETTERSETTER(Vector2,Offset,offset)
49  GETTERSETTER(Vector2,Target,target)
50  GETTERSETTER(float,Rotation,rotation)
51  GETTERSETTER(float,Zoom,zoom)
52 
53  Camera2D& operator=(const ::Camera2D& camera) {
54  set(camera);
55  return *this;
56  }
57 
58  Camera2D& operator=(const Camera2D& camera) {
59  set(camera);
60  return *this;
61  }
62 
63  inline Matrix GetMatrix() {
64  return ::GetCameraMatrix2D(*this);
65  }
66  inline Vector2 GetWorldToScreen2D(Vector2 position) {
67  return ::GetWorldToScreen2D(position, *this);
68  }
69  inline Vector2 GetScreenToWorld2D(Vector2 position) {
70  return ::GetScreenToWorld2D(position, *this);
71  }
72  };
73 }
74 
75 #endif
raylib
Provides all the classes associated with raylib-cpp.
Definition: AudioDevice.hpp:14
raylib::Camera2D::GetWorldToScreen2D
Vector2 GetWorldToScreen2D(Vector2 position)
Definition: Camera2D.hpp:66
raylib::Matrix
Definition: Matrix.hpp:21
raylib::Camera2D::GetMatrix
Matrix GetMatrix()
Definition: Camera2D.hpp:63
raylib::Camera2D::BeginMode2D
Camera2D & BeginMode2D()
Definition: Camera2D.hpp:39
raylib::Camera2D::set
void set(const ::Camera2D &camera)
Definition: Camera2D.hpp:25
raylib::Camera2D::operator=
Camera2D & operator=(const Camera2D &camera)
Definition: Camera2D.hpp:58
raylib::Camera2D
Definition: Camera2D.hpp:16
raylib::Camera2D::EndMode2D
Camera2D & EndMode2D()
Definition: Camera2D.hpp:43
raylib::Vector2
Definition: Vector2.hpp:22
raylib::Camera2D::set
void set(const Camera2D &camera)
Definition: Camera2D.hpp:32
raylib::Camera2D::GetScreenToWorld2D
Vector2 GetScreenToWorld2D(Vector2 position)
Definition: Camera2D.hpp:69
raylib::Camera2D::Camera2D
Camera2D(::Vector2 offsetValue, ::Vector2 targetValue, float rotationValue=0, float zoomValue=1)
Definition: Camera2D.hpp:18