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 Camera2D& BeginMode2D() {
26  ::BeginMode2D(*this);
27  return *this;
28  }
29  inline Camera2D& EndMode2D() {
30  ::EndMode2D();
31  return *this;
32  }
33 
34  GETTERSETTER(Vector2,Offset,offset)
35  GETTERSETTER(Vector2,Target,target)
36  GETTERSETTER(float,Rotation,rotation)
37  GETTERSETTER(float,Zoom,zoom)
38 
39  Camera2D& operator=(const ::Camera2D& camera) {
40  set(camera);
41  return *this;
42  }
43 
44  Camera2D& operator=(const Camera2D& camera) {
45  set(camera);
46  return *this;
47  }
48 
49  inline Matrix GetMatrix() const {
50  return ::GetCameraMatrix2D(*this);
51  }
52  inline Vector2 GetWorldToScreen2D(Vector2 position) const {
53  return ::GetWorldToScreen2D(position, *this);
54  }
55  inline Vector2 GetScreenToWorld2D(Vector2 position) const {
56  return ::GetScreenToWorld2D(position, *this);
57  }
58  protected:
59  inline void set(const ::Camera2D& camera) {
60  offset = camera.offset;
61  target = camera.target;
62  rotation = camera.rotation;
63  zoom = camera.zoom;
64  }
65 
66  inline void set(const Camera2D& camera) {
67  offset = camera.offset;
68  target = camera.target;
69  rotation = camera.rotation;
70  zoom = camera.zoom;
71  }
72  };
73 }
74 
75 #endif
raylib
Provides all the classes associated with raylib-cpp.
Definition: AudioDevice.hpp:14
raylib::Matrix
Definition: Matrix.hpp:21
raylib::Camera2D::GetMatrix
Matrix GetMatrix() const
Definition: Camera2D.hpp:49
raylib::Camera2D::GetScreenToWorld2D
Vector2 GetScreenToWorld2D(Vector2 position) const
Definition: Camera2D.hpp:55
raylib::Camera2D::BeginMode2D
Camera2D & BeginMode2D()
Definition: Camera2D.hpp:25
raylib::Camera2D::set
void set(const ::Camera2D &camera)
Definition: Camera2D.hpp:59
raylib::Camera2D::operator=
Camera2D & operator=(const Camera2D &camera)
Definition: Camera2D.hpp:44
raylib::Camera2D
Definition: Camera2D.hpp:16
raylib::Camera2D::EndMode2D
Camera2D & EndMode2D()
Definition: Camera2D.hpp:29
raylib::Vector2
Definition: Vector2.hpp:22
raylib::Camera2D::set
void set(const Camera2D &camera)
Definition: Camera2D.hpp:66
raylib::Camera2D::Camera2D
Camera2D(::Vector2 offsetValue, ::Vector2 targetValue, float rotationValue=0, float zoomValue=1)
Definition: Camera2D.hpp:18
raylib::Camera2D::GetWorldToScreen2D
Vector2 GetWorldToScreen2D(Vector2 position) const
Definition: Camera2D.hpp:52