Camera class complete
This commit is contained in:
2
TODO.txt
2
TODO.txt
@@ -17,7 +17,7 @@ CURRENT TODO LIST FOR THE DEVELOPMENT OF THE CRUMPET GAME ENGINE
|
||||
[x] x,y,w,h properties
|
||||
[ ] Switch other classes to use this instead of SDL_Rect* and make sure to update the render pipeline
|
||||
[x] Center point
|
||||
[ ] Maybe a point class
|
||||
[-] Maybe a point class - used Vec2*
|
||||
[ ] Game camera class and redo rendering pipeline
|
||||
[ ] Add rotation and flipping for entities and sprites
|
||||
[x] Camera class
|
||||
|
||||
@@ -1,7 +1,45 @@
|
||||
#include "camera.h"
|
||||
|
||||
Camera::Camera() {
|
||||
Camera::Camera(int screenWidth, int screenHeight) {
|
||||
Rect* res = new Rect(0, 0, screenWidth, screenHeight);
|
||||
m_view = res;
|
||||
}
|
||||
|
||||
void Camera::TranslateView(Vec2* offset) {
|
||||
m_view->Translate(offset);
|
||||
}
|
||||
|
||||
void Camera::TranslateViewX(int x) {
|
||||
m_view->TranslateX(x);
|
||||
}
|
||||
|
||||
void Camera::TranslateViewY(int y) {
|
||||
m_view->TranslateY(y);
|
||||
}
|
||||
|
||||
void Camera::SetSize(Vec2* size) {
|
||||
m_view->SetSize(size);
|
||||
}
|
||||
|
||||
void Camera::SetCenter(Vec2* point) {
|
||||
m_view->x = (point->x - m_view->CenterX());
|
||||
m_view->y = (point->y - m_view->CenterY());
|
||||
}
|
||||
|
||||
int Camera::GetX() {
|
||||
return m_view->x;
|
||||
}
|
||||
|
||||
int Camera::GetY() {
|
||||
return m_view->y;
|
||||
}
|
||||
|
||||
int Camera::GetW() {
|
||||
return m_view->w;
|
||||
}
|
||||
|
||||
int Camera::GetH() {
|
||||
return m_view->h;
|
||||
}
|
||||
|
||||
Camera::~Camera() {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
class Camera {
|
||||
public:
|
||||
Camera();
|
||||
Camera(int screenWidth, int screenHeight);
|
||||
void TranslateView(Vec2* offset);
|
||||
void TranslateViewX(int x);
|
||||
void TranslateViewY(int y);
|
||||
@@ -14,6 +14,11 @@ public:
|
||||
|
||||
void SetCenter(Vec2* point);
|
||||
|
||||
int GetX();
|
||||
int GetY();
|
||||
int GetW();
|
||||
int GetH();
|
||||
|
||||
virtual ~Camera();
|
||||
private:
|
||||
Rect* m_view;
|
||||
|
||||
Reference in New Issue
Block a user