|
|
@@ -3,15 +3,12 @@
|
|
|
#include "input/Input.h"
|
|
|
|
|
|
using WalrusRPG::Camera;
|
|
|
-using WalrusRPG::CameraCenterType;
|
|
|
using namespace WalrusRPG;
|
|
|
using WalrusRPG::Input::Key;
|
|
|
|
|
|
-Camera::Camera(signed x, signed y, CameraCenterType center_type)
|
|
|
-: x(x), y(y), render_area_width(320), render_area_height(240), center_type(center_type)
|
|
|
+Camera::Camera(signed x, signed y)
|
|
|
+: x(x), y(y), render_area_width(320), render_area_height(240)
|
|
|
{
|
|
|
- set_x(x);
|
|
|
- set_y(y);
|
|
|
}
|
|
|
|
|
|
Camera::~Camera()
|
|
|
@@ -43,27 +40,44 @@ void Camera::update(unsigned dt)
|
|
|
void Camera::set_x(signed x)
|
|
|
{
|
|
|
this->x = x;
|
|
|
- if(center_type == CENTER)
|
|
|
- this->x -= render_area_width/2;
|
|
|
}
|
|
|
|
|
|
signed Camera::get_x() const
|
|
|
{
|
|
|
- return center_type == CENTER? this->x + render_area_width/2 : this->x;
|
|
|
+ return this->x;
|
|
|
}
|
|
|
|
|
|
void Camera::set_y(signed y)
|
|
|
{
|
|
|
this->y = y;
|
|
|
- if(this->center_type == CENTER)
|
|
|
- this->y -= render_area_height/2;
|
|
|
}
|
|
|
|
|
|
signed Camera::get_y() const
|
|
|
{
|
|
|
- return center_type == CENTER? this->y + render_area_height/2 : this->y;
|
|
|
+ return this->y;
|
|
|
}
|
|
|
|
|
|
+void Camera::set_center_x(signed x)
|
|
|
+{
|
|
|
+ this->x = x - render_area_width/2;
|
|
|
+}
|
|
|
+
|
|
|
+signed Camera::get_center_x() const
|
|
|
+{
|
|
|
+ return this->x - render_area_height/2;
|
|
|
+}
|
|
|
+
|
|
|
+void Camera::set_center_y(signed y)
|
|
|
+{
|
|
|
+ this->y = y - render_area_width/2;
|
|
|
+}
|
|
|
+
|
|
|
+signed Camera::get_center_y() const
|
|
|
+{
|
|
|
+ return this->y - render_area_height/2;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
bool Camera::is_visible(const WalrusRPG::Utils::Rect &object) const
|
|
|
{
|
|
|
if ((in_range(object.x, x, x + (signed) render_area_width) ||
|
|
|
@@ -79,14 +93,4 @@ bool Camera::is_visible(const WalrusRPG::Utils::Rect &object) const
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
-}
|
|
|
-
|
|
|
-void Camera::set_center_type(CameraCenterType center_type)
|
|
|
-{
|
|
|
- this->center_type = center_type;
|
|
|
-}
|
|
|
-
|
|
|
-CameraCenterType Camera::get_center_type()
|
|
|
-{
|
|
|
- return this->center_type;
|
|
|
-}
|
|
|
+}
|