diff options
Diffstat (limited to 'src/crepe')
-rw-r--r-- | src/crepe/api/Animator.h | 21 | ||||
-rw-r--r-- | src/crepe/api/LoopManager.cpp | 4 | ||||
-rw-r--r-- | src/crepe/facade/SDLContext.cpp | 13 | ||||
-rw-r--r-- | src/crepe/facade/SDLContext.h | 1 | ||||
-rw-r--r-- | src/crepe/system/AnimatorSystem.cpp | 4 | ||||
-rw-r--r-- | src/crepe/system/RenderSystem.h | 2 |
6 files changed, 27 insertions, 18 deletions
diff --git a/src/crepe/api/Animator.h b/src/crepe/api/Animator.h index ede450a..0da0469 100644 --- a/src/crepe/api/Animator.h +++ b/src/crepe/api/Animator.h @@ -68,12 +68,21 @@ private: public: void loop() { this->looping = true; } - void play() {this->active = true;} - void pause() {this->active = false;} - void stop() {this->active = false; this->curr_col = 0; this->curr_row = 0;} - void set_fps(int fps) {this->fps = fps;} - void set_cycle_range(int start, int end) {this->cycle_start = start, this->cycle_end = end;} - void set_anim(int col) {this->curr_row = 0; this->curr_col = col; } + void play() { this->active = true; } + void pause() { this->active = false; } + void stop() { + this->active = false; + this->curr_col = 0; + this->curr_row = 0; + } + void set_fps(int fps) { this->fps = fps; } + void set_cycle_range(int start, int end) { + this->cycle_start = start, this->cycle_end = end; + } + void set_anim(int col) { + this->curr_row = 0; + this->curr_col = col; + } private: //! AnimatorSystem adjust the private member parameters of Animator; diff --git a/src/crepe/api/LoopManager.cpp b/src/crepe/api/LoopManager.cpp index 88ca704..51d9122 100644 --- a/src/crepe/api/LoopManager.cpp +++ b/src/crepe/api/LoopManager.cpp @@ -67,7 +67,7 @@ void LoopManager::render() { } } -void LoopManager::update() { - LoopTimer & timer = LoopTimer::get_instance(); +void LoopManager::update() { + LoopTimer & timer = LoopTimer::get_instance(); this->get_system<AnimatorSystem>().update(); } diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index f0a21d5..9c2ead4 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -113,11 +113,12 @@ SDL_Rect SDLContext::get_src_rect(const Sprite & sprite) const { SDL_FRect SDLContext::get_dst_rect(const DstRect & ctx) const { - - vec2 size = { - ctx.sprite.size.x == 0 && ctx.sprite.size.y != 0 ? ctx.sprite.size.y * ctx.sprite.aspect_ratio : ctx.sprite.size.x, - ctx.sprite.size.y == 0 && ctx.sprite.size.x != 0 ? ctx.sprite.size.x / ctx.sprite.aspect_ratio : ctx.sprite.size.y - }; + vec2 size = {ctx.sprite.size.x == 0 && ctx.sprite.size.y != 0 + ? ctx.sprite.size.y * ctx.sprite.aspect_ratio + : ctx.sprite.size.x, + ctx.sprite.size.y == 0 && ctx.sprite.size.x != 0 + ? ctx.sprite.size.x / ctx.sprite.aspect_ratio + : ctx.sprite.size.y}; const CameraValues & cam = ctx.cam; @@ -169,7 +170,7 @@ void SDLContext::set_camera(const Camera & cam, CameraValues & ctx) { double screen_aspect = static_cast<double>(cam.screen.x) / cam.screen.y; double viewport_aspect = zoomed_viewport.x / zoomed_viewport.y; - // calculate black bars + // calculate black bars if (screen_aspect > viewport_aspect) { // pillarboxing float scale = cam.screen.y / zoomed_viewport.y; diff --git a/src/crepe/facade/SDLContext.h b/src/crepe/facade/SDLContext.h index 285eee2..cd52be6 100644 --- a/src/crepe/facade/SDLContext.h +++ b/src/crepe/facade/SDLContext.h @@ -45,7 +45,6 @@ public: const double & scale; }; - public: /** * \brief Gets the singleton instance of SDLContext. diff --git a/src/crepe/system/AnimatorSystem.cpp b/src/crepe/system/AnimatorSystem.cpp index 6a84150..ee00728 100644 --- a/src/crepe/system/AnimatorSystem.cpp +++ b/src/crepe/system/AnimatorSystem.cpp @@ -22,11 +22,11 @@ void AnimatorSystem::update() { int cycle_end = (a.cycle_end == -1) ? a.row : cycle_end; int total_frames = cycle_end - a.cycle_start; - int curr_frame = static_cast<int>(elapsed_time / frame_duration) % total_frames; a.curr_row = a.cycle_start + curr_frame; - a.spritesheet.mask.x = std::clamp((a.curr_row * a.spritesheet.mask.w - a.offset_x), 0, a.spritesheet.mask.w); + a.spritesheet.mask.x = std::clamp((a.curr_row * a.spritesheet.mask.w - a.offset_x), 0, + a.spritesheet.mask.w); a.spritesheet.mask.y = (a.curr_col * a.spritesheet.mask.h); if (!a.looping && curr_frame == total_frames) { diff --git a/src/crepe/system/RenderSystem.h b/src/crepe/system/RenderSystem.h index 9ff015e..249f3b8 100644 --- a/src/crepe/system/RenderSystem.h +++ b/src/crepe/system/RenderSystem.h @@ -76,7 +76,7 @@ private: private: SDLContext & context = SDLContext::get_instance(); - + SDLContext::CameraValues cam_ctx; }; |