MCPcopy Create free account
hub / github.com/OneLoneCoder/olcPixelGameEngine / Camera2D

Class Camera2D

examples/TEST_Camera2D.cpp:66–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64namespace olc::utils
65{
66 class Camera2D
67 {
68 public:
69 enum class Mode : uint8_t
70 {
71 Simple, // No motion, just directly settable
72 EdgeMove, // Moves as target crosses boundary
73 LazyFollow, // Lazily follows the target
74 FixedScreens, // Moves statically between "screens"
75 SlideScreens, // MOves statically between "screens" but with a fast transition
76 };
77
78 public:
79 inline Camera2D() : m_pTarget(&m_vLocalTarget) {}
80
81 // Construct a camera with a viewable area size, and an optional starting position
82 inline Camera2D(const olc::vf2d& vViewSize, const olc::vf2d& vViewPos = { 0.0f, 0.0f }) : m_pTarget(&m_vLocalTarget)
83 {
84 m_vViewSize = vViewSize;
85 m_vViewPos = vViewPos;
86 }
87
88 // Set the operational mode of this camera
89 inline void SetMode(const Mode t)
90 {
91 m_nMode = t;
92 }
93
94 // Get the operational mode of this camera
95 inline Mode GetMode() const
96 {
97 return m_nMode;
98 }
99
100 // Get the position of the target being tracked by this camera
101 inline const olc::vf2d& GetTarget() const
102 {
103 return *m_pTarget;
104 }
105
106 // Get the position of the cameras focus point
107 inline const olc::vf2d& GetPosition() const
108 {
109 return m_vPosition;
110 }
111
112 // Get the top left of teh cameras visible area in world space
113 inline const olc::vf2d& GetViewPosition() const
114 {
115 return m_vViewPos;
116 }
117
118 // Get the camera's visible area
119 inline const olc::vf2d& GetViewSize() const
120 {
121 return m_vViewSize;
122 }
123

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected