Kaynağa Gözat

Changed Camera's coordonates type to allow negative positions

Florian DORMONT 10 yıl önce
ebeveyn
işleme
bc488312cd
2 değiştirilmiş dosya ile 12 ekleme ve 14 silme
  1. 7 8
      include/Camera.h
  2. 5 6
      src/Camera.cpp

+ 7 - 8
include/Camera.h

@@ -7,8 +7,8 @@ namespace WalrusRPG
 	{
 		protected:
 			// So, how will track camera's position? Top left or center?
-			unsigned x; // You'll probably want to switch over signed coordonates.
-			unsigned y;
+			signed x; // You'll probably want to switch over signed coordonates.
+			signed y;
 			unsigned render_area_width; // What if you only want to display the map on a part of the screen?
 			unsigned render_area_height;
 
@@ -19,18 +19,17 @@ namespace WalrusRPG
 			// Vector2 acceleration;
 
 		public:
-			Camera(unsigned x, unsigned y);
+			Camera(signed x, signed y);
 			~Camera();
 			// This doesn't need any render as it's the utility which helps rendering. Unless you want to show debnug things.
 			// void render(float dt) const;
 			void update(unsigned dt);
 
-			void set_x(unsigned x);
-			unsigned get_x() const;
-			void set_y(unsigned y);
-			unsigned get_y() const;
+			void set_x(signed x);
+			signed get_x() const;
+			void set_y(signed y);
+			signed get_y() const;
 	};
 }
 
 #endif
-

+ 5 - 6
src/Camera.cpp

@@ -5,7 +5,7 @@
 
 #define CAMERA WalrusRPG::Camera
 
-CAMERA::Camera(unsigned x, unsigned y)
+CAMERA::Camera(signed x, signed y)
 {
 	this->x = x;
 	this->y = y;
@@ -32,23 +32,22 @@ void CAMERA::update(unsigned dt)
 	if (isKeyPressed(KEY_NSPIRE_4)) x--;
 }
 
-void CAMERA::set_x(unsigned x)
+void CAMERA::set_x(signed x)
 {
 	this->x = x;
 }
 
-unsigned CAMERA::get_x() const
+signed CAMERA::get_x() const
 {
 	return this->x;
 }
 
-void CAMERA::set_y(unsigned y)
+void CAMERA::set_y(signed y)
 {
 	this->y = y;
 }
 
-unsigned CAMERA::get_y() const
+signed CAMERA::get_y() const
 {
 	return this->y;
 }
-