diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-02 21:00:54 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-02 21:00:54 +0100 |
commit | 0a1739de21e5ab270cb45efb6fc0aed092d81227 (patch) | |
tree | ab4019d595fce2410c5ca5d0fd98ad6d8205c079 /src/crepe/api | |
parent | a84ca09e97d466643f022acfffcf4c6a77f42052 (diff) |
added all the contructor strutcts for animator,sprite and camera
Diffstat (limited to 'src/crepe/api')
-rw-r--r-- | src/crepe/api/Animator.cpp | 15 | ||||
-rw-r--r-- | src/crepe/api/Animator.h | 8 | ||||
-rw-r--r-- | src/crepe/api/Camera.cpp | 1 |
3 files changed, 15 insertions, 9 deletions
diff --git a/src/crepe/api/Animator.cpp b/src/crepe/api/Animator.cpp index ce824e6..1234967 100644 --- a/src/crepe/api/Animator.cpp +++ b/src/crepe/api/Animator.cpp @@ -9,8 +9,7 @@ using namespace crepe; Animator::Animator(game_object_id_t id, const Animator::Data & ctx) : Component(id), - data(ctx) -{ + data(ctx) { dbg_trace(); this->data.spritesheet.mask.h /= this->data.col; @@ -23,21 +22,33 @@ Animator::Animator(game_object_id_t id, const Animator::Data & ctx) ss.data.aspect_ratio = static_cast<double>(this->data.spritesheet.mask.w) / this->data.spritesheet.mask.h; } + Animator::~Animator() { dbg_trace(); } void Animator::loop() { this->data.looping = true; } + void Animator::play() { this->active = true; } + void Animator::pause() { this->active = false; } + void Animator::stop() { this->active = false; this->data.curr_col = 0; this->data.curr_row = 0; } void Animator::set_fps(int fps) { this->data.fps = fps; } + void Animator::set_cycle_range(int start, int end) { this->data.cycle_start = start, this->data.cycle_end = end; } + void Animator::set_anim(int col) { this->data.curr_row = 0; this->data.curr_col = col; } + +void Animator::next_anim() { + Animator::Data & ctx = this->data; + ctx.curr_row = ctx.curr_row++ % ctx.row; + ctx.spritesheet.mask.x = ctx.curr_row * ctx.spritesheet.mask.w; +} diff --git a/src/crepe/api/Animator.h b/src/crepe/api/Animator.h index 194a9cf..36bc9f4 100644 --- a/src/crepe/api/Animator.h +++ b/src/crepe/api/Animator.h @@ -47,6 +47,7 @@ public: //! offset in pixels. + // TODO implement int offset_x = 0; }; @@ -108,12 +109,7 @@ 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 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. + * \param ctx animator data * * This constructor sets up the Animator with the given parameters, and initializes the * animation system. diff --git a/src/crepe/api/Camera.cpp b/src/crepe/api/Camera.cpp index 27bcb35..ff41710 100644 --- a/src/crepe/api/Camera.cpp +++ b/src/crepe/api/Camera.cpp @@ -7,7 +7,6 @@ using namespace crepe; Camera::Camera(game_object_id_t id, const Data & ctx) : Component(id), data(ctx) { - dbg_trace(); } |