aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/api')
-rw-r--r--src/crepe/api/Animator.h14
-rw-r--r--src/crepe/api/Camera.h26
-rw-r--r--src/crepe/api/Sprite.h36
-rw-r--r--src/crepe/api/Texture.cpp16
-rw-r--r--src/crepe/api/Texture.h1
5 files changed, 33 insertions, 60 deletions
diff --git a/src/crepe/api/Animator.h b/src/crepe/api/Animator.h
index ede1610..42ce957 100644
--- a/src/crepe/api/Animator.h
+++ b/src/crepe/api/Animator.h
@@ -28,11 +28,11 @@ public:
/**
* \brief Constructs an Animator object that will control animations for a sprite sheet.
*
- * \param[in] id The unique identifier for the component, typically assigned automatically.
- * \param[in] spritesheet A reference to the Sprite object which holds the sprite sheet for animation.
- * \param[in] row The maximum number of rows in the sprite sheet.
- * \param[in] col The maximum number of columns in the sprite sheet.
- * \param[in] col__animate The specific col index of the sprite sheet to animate. This allows selecting which col to animate from multiple col in the sheet.
+ * \param id The unique identifier for the component, typically assigned automatically.
+ * \param spritesheet A reference to the Sprite object which holds the sprite sheet for animation.
+ * \param row The maximum number of rows in the sprite sheet.
+ * \param col The maximum number of columns in the sprite sheet.
+ * \param col__animate The specific col index of the sprite sheet to animate. This allows selecting which col to animate from multiple col in the sheet.
*
* This constructor sets up the Animator with the given parameters, and initializes the animation system.
*/
@@ -80,8 +80,10 @@ private:
//int fps;
private:
- //! Friend class that can directly access the private members of the Animator.
+ //! AnimatorSystem adjust the private member parameters of Animator;
friend class AnimatorSystem;
+
+ //! SDLContext reads the Animator member var's
friend class SDLContext;
};
} // namespace crepe
diff --git a/src/crepe/api/Camera.h b/src/crepe/api/Camera.h
index 7587b44..708a523 100644
--- a/src/crepe/api/Camera.h
+++ b/src/crepe/api/Camera.h
@@ -2,8 +2,8 @@
#include <cstdint>
-#include "Component.h"
#include "Color.h"
+#include "Component.h"
namespace crepe {
@@ -31,34 +31,22 @@ public:
~Camera();
public:
- /**
- * \brief Background color of the camera view.
- */
+ //! \brief Background color of the camera view.
Color bg_color;
- /**
- * \brief Aspect ratio height for the camera.
- */
+ //! \brief Aspect ratio height for the camera.
double aspect_height;
- /**
- * \brief Aspect ratio width for the camera.
- */
+ //! \brief Aspect ratio width for the camera.
double aspect_width;
- /**
- * \brief X-coordinate of the camera position.
- */
+ //! \brief X-coordinate of the camera position.
double x;
- /**
- * \brief Y-coordinate of the camera position.
- */
+ //! \brief Y-coordinate of the camera position.
double y;
- /**
- * \brief Zoom level of the camera view.
- */
+ //! \brief Zoom level of the camera view.
double zoom;
public:
diff --git a/src/crepe/api/Sprite.h b/src/crepe/api/Sprite.h
index 51cb860..1db32d7 100644
--- a/src/crepe/api/Sprite.h
+++ b/src/crepe/api/Sprite.h
@@ -10,13 +10,6 @@
namespace crepe {
-/**
- * \struct Rect
- * \brief Represents a rectangle area for rendering.
- *
- * Everything within the defined rectangle will be rendered.
- * The SDLContext will translate this into the library's rectangle structure.
- */
struct Rect {
int w = 0;
int h = 0;
@@ -24,29 +17,16 @@ struct Rect {
int y = 0;
};
-/**
- * \struct FlipSettings
- * \brief Flip settings for the sprite.
- *
- * Defines the horizontal and vertical flip settings for a sprite, which the
- * SDLContext will translate into the corresponding settings for the library.
- */
struct FlipSettings {
bool flip_x = false;
bool flip_y = false;
};
-//! Forward declaration of the SDLContext facade.
class SDLContext;
-
-//! Forward declaration of the Animator class.
class Animator;
-
-//! Forward declaration of the AnimatorSystem class.
class AnimatorSystem;
/**
- * \class Sprite
* \brief Represents a renderable sprite component.
*
* A renderable sprite that can be displayed in the game. It includes a texture,
@@ -55,6 +35,9 @@ class AnimatorSystem;
class Sprite : public Component {
public:
+
+ // TODO: Loek comment in github #27 will be looked another time
+ // about shared_ptr Texture
/**
* \brief Constructs a Sprite with specified parameters.
* \param game_id Unique identifier for the game object this sprite belongs to.
@@ -78,23 +61,30 @@ public:
//! Flip settings for the sprite
FlipSettings flip;
//! Layer sorting level of the sprite
- uint8_t sorting_in_layer;
+ uint8_t sorting_in_layer = 0;
//! Order within the sorting layer
- uint8_t order_in_layer;
+ uint8_t order_in_layer = 0;
public:
/**
* \brief Gets the maximum number of instances allowed for this sprite.
* \return Maximum instance count as an integer.
+ *
+ * For now is this number randomly picked. I think it will eventually be 1.
*/
virtual int get_instances_max() const { return 10; }
private:
+ //! Reads the sprite_rect of sprite
friend class SDLContext;
+
+ //! Reads the all the variables plus the sprite_rect
friend class Animator;
+
+ //! Reads the all the variables plus the sprite_rect
friend class AnimatorSystem;
- //! Render area of the sprite
+ //! Render area of the sprite this will also be adjusted by the AnimatorSystem if an Animator object is present in GameObject
Rect sprite_rect;
};
diff --git a/src/crepe/api/Texture.cpp b/src/crepe/api/Texture.cpp
index 5519e5e..e6c2e05 100644
--- a/src/crepe/api/Texture.cpp
+++ b/src/crepe/api/Texture.cpp
@@ -32,18 +32,10 @@ void Texture::load(unique_ptr<Asset> res) {
}
int Texture::get_width() const{
- if (this->texture) {
- return SDLContext::get_instance().get_width(*this);
- }
- else {
- return 0;
- }
+ if (this->texture == nullptr) return 0;
+ return SDLContext::get_instance().get_width(*this);
}
int Texture::get_height() const{
- if (this->texture) {
- return SDLContext::get_instance().get_height(*this);
- }
- else {
- return 0;
- }
+ if (this->texture == nullptr) return 0;
+ return SDLContext::get_instance().get_width(*this);
}
diff --git a/src/crepe/api/Texture.h b/src/crepe/api/Texture.h
index 6d99a93..828518d 100644
--- a/src/crepe/api/Texture.h
+++ b/src/crepe/api/Texture.h
@@ -64,6 +64,7 @@ private:
void load(std::unique_ptr<Asset> res);
private:
+ //TODO make RAII
//! The texture of the class from the library
SDL_Texture * texture = nullptr;