aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/api')
-rw-r--r--src/crepe/api/Animator.cpp2
-rw-r--r--src/crepe/api/Animator.h26
-rw-r--r--src/crepe/api/Camera.h2
-rw-r--r--src/crepe/api/Sprite.h12
4 files changed, 25 insertions, 17 deletions
diff --git a/src/crepe/api/Animator.cpp b/src/crepe/api/Animator.cpp
index dc99fd4..8b91859 100644
--- a/src/crepe/api/Animator.cpp
+++ b/src/crepe/api/Animator.cpp
@@ -7,7 +7,7 @@
using namespace crepe;
-Animator::Animator(uint32_t id, Sprite & ss, int max_row, int max_col,
+Animator::Animator(uint32_t id, Sprite & ss, unsigned int max_row, unsigned int max_col,
const Animator::Data & ctx)
: Component(id),
spritesheet(ss),
diff --git a/src/crepe/api/Animator.h b/src/crepe/api/Animator.h
index dab6697..e0399a8 100644
--- a/src/crepe/api/Animator.h
+++ b/src/crepe/api/Animator.h
@@ -2,6 +2,8 @@
#include "Component.h"
#include "Sprite.h"
+#include "types.h"
+#include <sys/types.h>
namespace crepe {
@@ -20,26 +22,26 @@ public:
struct Data {
//! frames per second for animation
- int fps = 1;
+ unsigned int fps = 1;
//! The current col being animated.
- int curr_col = 0;
+ unsigned int curr_col = 0;
//! The current row being animated.
- int curr_row = 0;
+ unsigned int curr_row = 0;
//! should the animation loop
bool looping = false;
//! starting frame for cycling
- int cycle_start = 0;
+ unsigned int cycle_start = 0;
//! end frame for cycling (-1 --> use last frame)
int cycle_end = -1;
//! offset in pixels.
// TODO implement
- int offset_x = 0;
+ unsigned int white_space = 0;
};
public:
@@ -100,12 +102,15 @@ public:
* \brief Constructs an Animator object that will control animations for a sprite sheet.
*
* \param id The unique identifier for the component, typically assigned automatically.
- * \param ctx animator data
+ * \param ss the reference to the spritesheet
+ * \param max_row maximum of rows inside the given spritesheet
+ * \param max_col maximum of columns inside the given spritesheet
+ * \param ctx extra animation data for more control
*
* This constructor sets up the Animator with the given parameters, and initializes the
* animation system.
*/
- Animator(uint32_t id, Sprite & ss, int max_row, int max_col, const Animator::Data & ctx);
+ Animator(game_object_id_t id, Sprite & ss, unsigned int max_row, unsigned int max_col, const Animator::Data & ctx);
~Animator(); // dbg_trace
public:
@@ -113,16 +118,13 @@ public:
Sprite & spritesheet;
//! The maximum number of columns in the sprite sheet.
- const int col;
+ const unsigned int col;
//! The maximum number of rows in the sprite sheet.
- const int row;
+ const unsigned int row;
Animator::Data data;
-private:
- //! AnimatorSystem adjust the private member parameters of Animator;
- friend class AnimatorSystem;
};
} // namespace crepe
//
diff --git a/src/crepe/api/Camera.h b/src/crepe/api/Camera.h
index f626379..84ca9e1 100644
--- a/src/crepe/api/Camera.h
+++ b/src/crepe/api/Camera.h
@@ -23,7 +23,7 @@ public:
double zoom = 1;
//! offset postion from the game object transform component
- vec2 offset;
+ vec2 postion_offset;
};
public:
diff --git a/src/crepe/api/Sprite.h b/src/crepe/api/Sprite.h
index a1230db..0ccc296 100644
--- a/src/crepe/api/Sprite.h
+++ b/src/crepe/api/Sprite.h
@@ -20,11 +20,14 @@ class AnimatorSystem;
*/
class Sprite : public Component {
public:
+ //! settings to flip the image
struct FlipSettings {
+ //! horizantal flip
bool flip_x = false;
+ //! vertical flip
bool flip_y = false;
};
-
+
struct Data {
//! Color tint of the sprite
Color color = Color::WHITE;
@@ -50,10 +53,13 @@ public:
vec2 size;
//! independent sprite angle. rotating clockwise direction in degrees
- double angle_offset = 0;
+ float angle_offset = 0;
//! independent sprite scale multiplier
- double scale_offset = 1;
+ float scale_offset = 1;
+
+ //! independent sprite offset position
+ vec2 position_offset;
};
public: