aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/api')
-rw-r--r--src/crepe/api/Camera.h4
-rw-r--r--src/crepe/api/Sprite.cpp4
-rw-r--r--src/crepe/api/Sprite.h8
-rw-r--r--src/crepe/api/Vector2.cpp4
-rw-r--r--src/crepe/api/Vector2.h3
5 files changed, 19 insertions, 4 deletions
diff --git a/src/crepe/api/Camera.h b/src/crepe/api/Camera.h
index c42ed0d..083dc19 100644
--- a/src/crepe/api/Camera.h
+++ b/src/crepe/api/Camera.h
@@ -38,10 +38,8 @@ public:
Vector2 viewport = {2000, 1000};
//! scale scaling factor from world units to pixel coordinates
- Vector2 scale = {0, 0};
-
//! Zoom level of the camera view.
- double zoom = 1.0f;
+ double zoom = 1.5f;
public:
/**
diff --git a/src/crepe/api/Sprite.cpp b/src/crepe/api/Sprite.cpp
index bd2d5cf..3853aab 100644
--- a/src/crepe/api/Sprite.cpp
+++ b/src/crepe/api/Sprite.cpp
@@ -15,7 +15,9 @@ Sprite::Sprite(game_object_id_t id, const shared_ptr<Texture> image, const Color
: Component(id),
color(color),
flip(flip),
- sprite_image(image) {
+ sprite_image(image),
+ aspect_ratio(sprite_image->get_width() / sprite_image->get_height())
+{
dbg_trace();
this->sprite_rect.w = sprite_image->get_width();
diff --git a/src/crepe/api/Sprite.h b/src/crepe/api/Sprite.h
index 74a55d4..66599c9 100644
--- a/src/crepe/api/Sprite.h
+++ b/src/crepe/api/Sprite.h
@@ -1,6 +1,7 @@
#pragma once
#include <memory>
+#include <sys/types.h>
#include "../Component.h"
@@ -62,6 +63,13 @@ public:
//! Order within the sorting layer
uint8_t order_in_layer = 0;
+ //! width in world units
+ int width = 0;
+ //! height in world units
+ int height = 0;
+
+ const double aspect_ratio;
+
public:
/**
* \brief Gets the maximum number of instances allowed for this sprite.
diff --git a/src/crepe/api/Vector2.cpp b/src/crepe/api/Vector2.cpp
index 8658c00..c8253d7 100644
--- a/src/crepe/api/Vector2.cpp
+++ b/src/crepe/api/Vector2.cpp
@@ -40,6 +40,10 @@ Vector2 Vector2::operator/(const Vector2 & other) const {
return {this->x / other.x, this->y / other.y};
}
+Vector2 Vector2::operator/(const double & other) const {
+ return {this->x / other, this->y / other};
+}
+
Vector2 Vector2::operator-() const { return {-x, -y}; }
bool Vector2::operator==(const Vector2 & other) const { return x == other.x && y == other.y; }
diff --git a/src/crepe/api/Vector2.h b/src/crepe/api/Vector2.h
index 790160d..5a23699 100644
--- a/src/crepe/api/Vector2.h
+++ b/src/crepe/api/Vector2.h
@@ -30,6 +30,9 @@ struct Vector2 {
//! Divides this vector by another vector element-wise and updates this vector.
Vector2 operator/(const Vector2 & other) const;
+ //! Divides a scalar value to both components of this vector and updates this vector.
+ Vector2 operator/(const double & other) const;
+
//! Adds another vector to this vector and updates this vector.
Vector2 & operator+=(const Vector2 & other);