aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-27 19:57:16 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-27 19:57:16 +0100
commitddb5bde6e5dd4d89faf419630086ece66690d6b5 (patch)
tree0b2cf988dbee4915fca002f16fbe88013d075ce2 /src/crepe/api
parent2b35e8f51a3536b62ea21dc82deec1e3b65568f6 (diff)
implemented feedback. biggest changes are teh camera_ref removed
Diffstat (limited to 'src/crepe/api')
-rw-r--r--src/crepe/api/Animator.h5
-rw-r--r--src/crepe/api/Camera.cpp8
-rw-r--r--src/crepe/api/Camera.h12
-rw-r--r--src/crepe/api/Config.h4
-rw-r--r--src/crepe/api/Sprite.cpp8
-rw-r--r--src/crepe/api/Sprite.h18
-rw-r--r--src/crepe/api/Vector2.h1
7 files changed, 31 insertions, 25 deletions
diff --git a/src/crepe/api/Animator.h b/src/crepe/api/Animator.h
index 53f4b91..7a5ef03 100644
--- a/src/crepe/api/Animator.h
+++ b/src/crepe/api/Animator.h
@@ -40,11 +40,6 @@ public:
Animator(uint32_t id, Sprite & spritesheet, int row, int col, int col_animate);
~Animator(); // dbg_trace
- Animator(const Animator &) = delete;
- Animator(Animator &&) = delete;
- Animator & operator=(const Animator &) = delete;
- Animator & operator=(Animator &&) = delete;
-
private:
//! A reference to the Sprite sheet containing the animation frames.
Sprite & spritesheet;
diff --git a/src/crepe/api/Camera.cpp b/src/crepe/api/Camera.cpp
index 5835bdd..4397ac7 100644
--- a/src/crepe/api/Camera.cpp
+++ b/src/crepe/api/Camera.cpp
@@ -6,9 +6,13 @@
using namespace crepe;
-Camera::Camera(game_object_id_t id, const Color & bg_color)
+Camera::Camera(game_object_id_t id, const Color & bg_color, const ivec2 & screen,
+ const ivec2 & viewport, const double & zoom)
: Component(id),
- bg_color(bg_color) {
+ bg_color(bg_color),
+ screen(screen),
+ viewport(viewport),
+ zoom(zoom) {
dbg_trace();
}
diff --git a/src/crepe/api/Camera.h b/src/crepe/api/Camera.h
index 1505107..2ba37fc 100644
--- a/src/crepe/api/Camera.h
+++ b/src/crepe/api/Camera.h
@@ -21,12 +21,12 @@ public:
* \param id Unique identifier for the camera component.
* \param bg_color Background color for the camera view.
*/
- Camera(game_object_id_t id, const Color & bg_color);
+ Camera(game_object_id_t id, const Color & bg_color, const ivec2 & screen, const ivec2 & viewport, const double & zoom);
~Camera(); // dbg_trace only
public:
//! Background color of the camera view.
- Color bg_color;
+ const Color bg_color;
//! offset postion from the game object transform component
vec2 offset = {0, 0};
@@ -36,19 +36,19 @@ public:
vec2 pos = {0, 0};
//! screen the display size in pixels ( output resolution )
- ivec2 screen = {1080, 720};
+ const ivec2 screen = {1080, 720};
//! viewport is the area of the world visible through the camera (in world units)
- ivec2 viewport = {500, 1000};
+ const ivec2 viewport = {500, 1000};
//! Zoom level of the camera view.
- double zoom = 1.0f;
+ const double zoom = 1.0f;
public:
/**
* \brief Gets the maximum number of camera instances allowed.
* \return Maximum instance count as an integer.
*/
- virtual int get_instances_max() const { return 10; }
+ virtual int get_instances_max() const { return 1; }
};
} // namespace crepe
diff --git a/src/crepe/api/Config.h b/src/crepe/api/Config.h
index 2723461..9b43cdf 100644
--- a/src/crepe/api/Config.h
+++ b/src/crepe/api/Config.h
@@ -66,9 +66,7 @@ public:
//! default window settings
struct {
//TODO make this constexpr because this will never change
- ivec2 def_size = {1080, 720};
- vec2 pos = {0, 0};
- float zoom = 1.0f;
+ const ivec2 def_size = {1080, 720};
} win_set;
//! Asset loading options
diff --git a/src/crepe/api/Sprite.cpp b/src/crepe/api/Sprite.cpp
index 2c2ca65..21c8377 100644
--- a/src/crepe/api/Sprite.cpp
+++ b/src/crepe/api/Sprite.cpp
@@ -10,16 +10,20 @@ using namespace std;
using namespace crepe;
Sprite::Sprite(game_object_id_t id, const Texture & image, const Color & color,
- const FlipSettings & flip)
+ const FlipSettings & flip, uint8_t sort_layer, uint8_t order_layer, int height)
: Component(id),
color(color),
flip(flip),
sprite_image(image),
- aspect_ratio(static_cast<double>(sprite_image.get_width()) / sprite_image.get_height()) {
+ sorting_in_layer(sort_layer),
+ order_in_layer(order_layer),
+ height(height) {
+
dbg_trace();
this->sprite_rect.w = sprite_image.get_width();
this->sprite_rect.h = sprite_image.get_height();
+ this->aspect_ratio = static_cast<double>(this->sprite_rect.w) / this->sprite_rect.h;
}
Sprite::~Sprite() { dbg_trace(); }
diff --git a/src/crepe/api/Sprite.h b/src/crepe/api/Sprite.h
index 82dc4a7..1c40501 100644
--- a/src/crepe/api/Sprite.h
+++ b/src/crepe/api/Sprite.h
@@ -1,12 +1,10 @@
#pragma once
-#include <memory>
-#include <sys/types.h>
-
#include "../Component.h"
#include "Color.h"
#include "Texture.h"
+#include <cstdint>
namespace crepe {
@@ -43,9 +41,12 @@ public:
* \param image Shared pointer to the texture for this sprite.
* \param color Color tint applied to the sprite.
* \param flip Flip settings for horizontal and vertical orientation.
+ * \param order_layer decides the sorting in layer of the sprite.
+ * \param sort_layer decides the order in layer of the sprite.
+ * \param height the height of the image in game units
*/
Sprite(game_object_id_t id, const Texture & image, const Color & color,
- const FlipSettings & flip);
+ const FlipSettings & flip, uint8_t sort_layer, uint8_t order_layer, int height);
/**
* \brief Destroys the Sprite instance.
@@ -54,17 +55,20 @@ public:
//! Texture used for the sprite
const Texture & sprite_image;
+
//! Color tint of the sprite
Color color;
+
//! Flip settings for the sprite
FlipSettings flip;
+
//! Layer sorting level of the sprite
- uint8_t sorting_in_layer = 0;
+ const uint8_t sorting_in_layer;
//! Order within the sorting layer
- uint8_t order_in_layer = 0;
+ const uint8_t order_in_layer;
//! height in world units
- int height = 0;
+ const int height;
/**
* \aspect_ratio ratio of the img so that scaling will not become weird
diff --git a/src/crepe/api/Vector2.h b/src/crepe/api/Vector2.h
index 0688fac..2b31d90 100644
--- a/src/crepe/api/Vector2.h
+++ b/src/crepe/api/Vector2.h
@@ -37,6 +37,7 @@ struct Vector2 {
//! Divides a scalar value to both components of this vector and updates this vector.
Vector2 operator/(const T & other) const;
+ //! Divides a scalar value to both components of this vector and updates this vector.
Vector2 operator/(T other) const;
//! Adds another vector to this vector and updates this vector.