diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/crepe/api/Animator.h | 1 | ||||
-rw-r--r-- | src/crepe/api/Sprite.h | 1 | ||||
-rw-r--r-- | src/crepe/facade/SDLContext.cpp | 11 | ||||
-rw-r--r-- | src/crepe/system/RenderSystem.cpp | 3 | ||||
-rw-r--r-- | src/crepe/system/RenderSystem.h | 6 | ||||
-rw-r--r-- | src/example/rendering_particle.cpp | 16 |
6 files changed, 20 insertions, 18 deletions
diff --git a/src/crepe/api/Animator.h b/src/crepe/api/Animator.h index 1fe2b6f..dab6697 100644 --- a/src/crepe/api/Animator.h +++ b/src/crepe/api/Animator.h @@ -19,7 +19,6 @@ class Animator : public Component { public: struct Data { - //! frames per second for animation int fps = 1; diff --git a/src/crepe/api/Sprite.h b/src/crepe/api/Sprite.h index d82ae8d..a1230db 100644 --- a/src/crepe/api/Sprite.h +++ b/src/crepe/api/Sprite.h @@ -54,7 +54,6 @@ public: //! independent sprite scale multiplier double scale_offset = 1; - }; public: diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index d3a15d9..86969ed 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -114,9 +114,10 @@ SDL_FRect SDLContext::get_dst_rect(const DstRect & ctx) const { const Sprite::Data & data = ctx.sprite.data; - vec2 size = { - data.size.x == 0 && data.size.y != 0 ? data.size.y * ctx.sprite.aspect_ratio : data.size.x, - data.size.y == 0 && data.size.x != 0 ? data.size.x / ctx.sprite.aspect_ratio : data.size.y}; + vec2 size = {data.size.x == 0 && data.size.y != 0 ? data.size.y * ctx.sprite.aspect_ratio + : data.size.x, + data.size.y == 0 && data.size.x != 0 ? data.size.x / ctx.sprite.aspect_ratio + : data.size.y}; const CameraValues & cam = ctx.cam; @@ -180,8 +181,7 @@ SDLContext::CameraValues SDLContext::set_camera(const Camera & cam) { float adj_width = zoomed_viewport.x * scale; float bar_width = (cam.screen.x - adj_width) / 2; this->black_bars[0] = {0, 0, bar_width, (float) cam.screen.y}; - this->black_bars[1] - = {(cam.screen.x - bar_width), 0, bar_width, (float) cam.screen.y}; + this->black_bars[1] = {(cam.screen.x - bar_width), 0, bar_width, (float) cam.screen.y}; bar_size = {bar_width, 0}; render_scale.x = render_scale.y = scale; @@ -211,7 +211,6 @@ SDLContext::CameraValues SDLContext::set_camera(const Camera & cam) { // fill bg color SDL_RenderFillRect(this->game_renderer.get(), &bg); - return ret_cam; } diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp index b5db45a..4c618d8 100644 --- a/src/crepe/system/RenderSystem.cpp +++ b/src/crepe/system/RenderSystem.cpp @@ -89,7 +89,8 @@ bool RenderSystem::render_particle(const Sprite & sprite, const SDLContext::Came } return rendering_particles; } -void RenderSystem::render_normal(const Sprite & sprite, const SDLContext::CameraValues & cam, const Transform & tm) { +void RenderSystem::render_normal(const Sprite & sprite, const SDLContext::CameraValues & cam, + const Transform & tm) { this->context.draw(SDLContext::RenderContext{ .sprite = sprite, .cam = cam, diff --git a/src/crepe/system/RenderSystem.h b/src/crepe/system/RenderSystem.h index e779047..9c306c5 100644 --- a/src/crepe/system/RenderSystem.h +++ b/src/crepe/system/RenderSystem.h @@ -49,7 +49,8 @@ private: * \param tm the Transform component for scale * \return true if particles have been rendered */ - bool render_particle(const Sprite & sprite, const SDLContext::CameraValues & cam, const double & scale); + bool render_particle(const Sprite & sprite, const SDLContext::CameraValues & cam, + const double & scale); /** * \brief renders a sprite with a Transform component on the screen @@ -57,7 +58,8 @@ private: * \param sprite the sprite component that holds all the data * \param tm the Transform component that holds the position,rotation and scale */ - void render_normal(const Sprite & sprite, const SDLContext::CameraValues & cam, const Transform & tm); + void render_normal(const Sprite & sprite, const SDLContext::CameraValues & cam, + const Transform & tm); /** * \brief sort a vector sprite objects with diff --git a/src/example/rendering_particle.cpp b/src/example/rendering_particle.cpp index 2e2552d..07e43a1 100644 --- a/src/example/rendering_particle.cpp +++ b/src/example/rendering_particle.cpp @@ -63,16 +63,18 @@ public: .angle_offset = 0, }); - auto & anim = game_object.add_component<Animator>(test_sprite, 4, 4, Animator::Data{ - .fps = 1, - .looping = false, - }); + auto & anim = game_object.add_component<Animator>(test_sprite, 4, 4, + Animator::Data{ + .fps = 1, + .looping = false, + }); anim.set_anim(2); anim.active = false; - auto & cam = game_object.add_component<Camera>(ivec2{1280,720}, vec2{400,400},Camera::Data{ - .bg_color = Color::WHITE, - }); + auto & cam = game_object.add_component<Camera>(ivec2{1280, 720}, vec2{400, 400}, + Camera::Data{ + .bg_color = Color::WHITE, + }); } string get_name() const { return "TestScene"; }; |