aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-18 20:12:31 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-18 20:12:31 +0100
commit88f613cbb2e4aaf3ed55ac0c6490706dd6f6f19d (patch)
tree8db09f0a0f27dc552356a6c5513589245e9ff7b7 /src/crepe/api
parent9288e4964526f1ce6b7d0aca0f075a04f56ede32 (diff)
rendering based on world unites instead of pixels
Diffstat (limited to 'src/crepe/api')
-rw-r--r--src/crepe/api/Animator.cpp2
-rw-r--r--src/crepe/api/Camera.h39
2 files changed, 17 insertions, 24 deletions
diff --git a/src/crepe/api/Animator.cpp b/src/crepe/api/Animator.cpp
index 464b0fd..f3d809c 100644
--- a/src/crepe/api/Animator.cpp
+++ b/src/crepe/api/Animator.cpp
@@ -18,7 +18,7 @@ Animator::Animator(game_object_id_t id, Sprite & ss, int row, int col, int col_a
animator_rect.h /= col;
animator_rect.w /= row;
animator_rect.x = 0;
- animator_rect.y = col_animator * animator_rect.h;
+ animator_rect.y = (col_animator - 1)* animator_rect.h;
this->active = false;
}
Animator::~Animator() { dbg_trace(); }
diff --git a/src/crepe/api/Camera.h b/src/crepe/api/Camera.h
index 73d4ef4..dfccd24 100644
--- a/src/crepe/api/Camera.h
+++ b/src/crepe/api/Camera.h
@@ -28,32 +28,25 @@ public:
//! Background color of the camera view.
Color bg_color;
- Vector2 pos = {0,0};
-
- Vector2 screen = {640,480};
-
- Vector2 viewport = {500,500};
-
- /*
- //! screen width in pixel coordinates
- double screen_w = 480;
-
- //! screen height in pixel coordinates
- double screen_h = 640;
-
- //! screen widht in world units
- double viewport_w = 500.0f;
-
- //! screen height in world units
- double viewport_h = 500.0f;
+ /**
+ * \pos The position of the camera in world units
+ */
+ Vector2 pos = {0, 0};
- //! X-coordinate of the camera position. in world space
- double x = 0.0;
+ /**
+ * \screen the display size in pixels ( output resolution )
+ */
+ Vector2 screen = {640, 480};
- //! Y-coordinate of the camera position. in world space
- double y = 0.0;
+ /**
+ * \viewport is the area of the world visible through the camera (in world units)
+ */
+ Vector2 viewport = {500, 500};
- */
+ /**
+ * \scale scaling factor from world units to pixel coordinates
+ */
+ Vector2 scale = {0,0};
//! Zoom level of the camera view.
double zoom = 1.0f;