diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/crepe/api/Animator.cpp | 3 | ||||
-rw-r--r-- | src/crepe/api/Texture.cpp | 16 | ||||
-rw-r--r-- | src/crepe/api/Texture.h | 10 | ||||
-rw-r--r-- | src/crepe/facade/SDLContext.h | 9 | ||||
-rw-r--r-- | src/crepe/system/RenderSystem.cpp | 2 | ||||
-rw-r--r-- | src/crepe/system/RenderSystem.h | 2 | ||||
-rw-r--r-- | src/example/rendering_particle.cpp | 4 | ||||
-rw-r--r-- | src/test/ParticleTest.cpp | 3 | ||||
-rw-r--r-- | src/test/RenderSystemTest.cpp | 20 |
9 files changed, 31 insertions, 38 deletions
diff --git a/src/crepe/api/Animator.cpp b/src/crepe/api/Animator.cpp index 31b9632..2b21c6c 100644 --- a/src/crepe/api/Animator.cpp +++ b/src/crepe/api/Animator.cpp @@ -21,6 +21,7 @@ Animator::Animator(game_object_id_t id, Sprite & ss, int row, int col, int col_a this->active = false; // need to do this for to get the aspect ratio for a single clipping in the spritesheet - this->spritesheet.aspect_ratio = static_cast<double>(this->spritesheet.sprite_rect.w) / this->spritesheet.sprite_rect.h; + this->spritesheet.aspect_ratio = static_cast<double>(this->spritesheet.sprite_rect.w) + / this->spritesheet.sprite_rect.h; } Animator::~Animator() { dbg_trace(); } diff --git a/src/crepe/api/Texture.cpp b/src/crepe/api/Texture.cpp index 576bdc3..e43bdaa 100644 --- a/src/crepe/api/Texture.cpp +++ b/src/crepe/api/Texture.cpp @@ -17,15 +17,13 @@ Texture::~Texture() { this->texture.reset(); } -Texture::Texture(Texture&& other) noexcept - : texture(std::move(other.texture)){ -} - -Texture& Texture::operator=(Texture&& other) noexcept { - if (this != &other) { - texture = std::move(other.texture); - } - return *this; +Texture::Texture(Texture && other) noexcept : texture(std::move(other.texture)) {} + +Texture & Texture::operator=(Texture && other) noexcept { + if (this != &other) { + texture = std::move(other.texture); + } + return *this; } void Texture::load(const Asset & res) { diff --git a/src/crepe/api/Texture.h b/src/crepe/api/Texture.h index dc4a6d7..7206a66 100644 --- a/src/crepe/api/Texture.h +++ b/src/crepe/api/Texture.h @@ -35,11 +35,11 @@ public: */ ~Texture(); // FIXME: this constructor shouldn't be necessary because this class doesn't manage memory - - Texture(Texture&& other) noexcept; - Texture& operator=(Texture&& other) noexcept; - Texture(const Texture&) = delete; - Texture& operator=(const Texture&) = delete; + + Texture(Texture && other) noexcept; + Texture & operator=(Texture && other) noexcept; + Texture(const Texture &) = delete; + Texture & operator=(const Texture &) = delete; /** * \brief Gets the width of the texture. diff --git a/src/crepe/facade/SDLContext.h b/src/crepe/facade/SDLContext.h index 25f2818..5f141be 100644 --- a/src/crepe/facade/SDLContext.h +++ b/src/crepe/facade/SDLContext.h @@ -16,14 +16,13 @@ namespace crepe { -struct RenderCtx{ +struct RenderCtx { const Sprite & sprite; const Camera & cam; const vec2 & cam_pos; const vec2 & pos; const double & angle; const double & scale; - }; // TODO: SDL_Keycode is defined in a header not distributed with crepe, which means this @@ -39,8 +38,6 @@ typedef SDL_Keycode CREPE_KEYCODES; */ class SDLContext { - - public: /** * \brief Gets the singleton instance of SDLContext. @@ -161,8 +158,8 @@ private: * \param img_scale the image multiplier for increasing img size * \return sdl rectangle to draw a dst image to draw on the screen */ - SDL_Rect get_dst_rect(const Sprite & sprite, const vec2 & pos, const Camera & cam, const vec2 & cam_pos, - const double & img_scale) const; + SDL_Rect get_dst_rect(const Sprite & sprite, const vec2 & pos, const Camera & cam, + const vec2 & cam_pos, const double & img_scale) const; private: //! sdl Window diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp index 0bef69b..8895f02 100644 --- a/src/crepe/system/RenderSystem.cpp +++ b/src/crepe/system/RenderSystem.cpp @@ -6,10 +6,10 @@ #include <vector> #include "../ComponentManager.h" +#include "../api/Camera.h" #include "../api/ParticleEmitter.h" #include "../api/Sprite.h" #include "../api/Transform.h" -#include "../api/Camera.h" #include "../facade/SDLContext.h" #include "RenderSystem.h" diff --git a/src/crepe/system/RenderSystem.h b/src/crepe/system/RenderSystem.h index 7279b5c..e70831e 100644 --- a/src/crepe/system/RenderSystem.h +++ b/src/crepe/system/RenderSystem.h @@ -13,7 +13,6 @@ class Camera; class Sprite; class Transform; - /** * \class RenderSystem * \brief Manages rendering operations for all game objects. @@ -80,7 +79,6 @@ private: //! camera postion in the current scene vec2 cam_pos; - }; } // namespace crepe diff --git a/src/example/rendering_particle.cpp b/src/example/rendering_particle.cpp index 68dadd7..8fdbb58 100644 --- a/src/example/rendering_particle.cpp +++ b/src/example/rendering_particle.cpp @@ -31,8 +31,8 @@ int main(int argc, char * argv[]) { Color color(255, 255, 255, 255); auto img = Texture("asset/texture/test_ap43.png"); - Sprite & test_sprite - = game_object.add_component<Sprite>(img, color, Sprite::FlipSettings{true, true}, 1, 1, 500); + Sprite & test_sprite = game_object.add_component<Sprite>( + img, color, Sprite::FlipSettings{true, true}, 1, 1, 500); //game_object.add_component<Animator>(test_sprite, 4, 1, 0).active = true; game_object.add_component<Animator>(test_sprite, 1, 1, 0).active = true; diff --git a/src/test/ParticleTest.cpp b/src/test/ParticleTest.cpp index 1ac058f..976f9a1 100644 --- a/src/test/ParticleTest.cpp +++ b/src/test/ParticleTest.cpp @@ -30,8 +30,7 @@ public: Color color(0, 0, 0, 0); auto s1 = Texture("asset/texture/img.png"); Sprite & test_sprite = game_object.add_component<Sprite>( - s1, color, - Sprite::FlipSettings{true, true}, 1,1,100); + s1, color, Sprite::FlipSettings{true, true}, 1, 1, 100); game_object.add_component<ParticleEmitter>(ParticleEmitter::Data{ .position = {0, 0}, diff --git a/src/test/RenderSystemTest.cpp b/src/test/RenderSystemTest.cpp index 138aa36..e0bd953 100644 --- a/src/test/RenderSystemTest.cpp +++ b/src/test/RenderSystemTest.cpp @@ -7,12 +7,12 @@ #define private public #define protected public +#include "crepe/api/Camera.h" #include <crepe/ComponentManager.h> #include <crepe/api/Color.h> #include <crepe/api/GameObject.h> #include <crepe/api/Sprite.h> #include <crepe/api/Texture.h> -#include "crepe/api/Camera.h" #include <crepe/system/RenderSystem.h> @@ -34,25 +34,25 @@ public: auto s2 = Texture("asset/texture/img.png"); auto s3 = Texture("asset/texture/img.png"); auto s4 = Texture("asset/texture/img.png"); - auto & sprite1 = entity1.add_component<Sprite>(s1, Color(0, 0, 0, 0), - Sprite::FlipSettings{false, false}, 5, 5, 100); + auto & sprite1 = entity1.add_component<Sprite>( + s1, Color(0, 0, 0, 0), Sprite::FlipSettings{false, false}, 5, 5, 100); ASSERT_NE(sprite1.sprite_image.texture.get(), nullptr); EXPECT_EQ(sprite1.order_in_layer, 5); EXPECT_EQ(sprite1.sorting_in_layer, 5); - auto & sprite2 = entity2.add_component<Sprite>(s2, Color(0, 0, 0, 0), - Sprite::FlipSettings{false, false}, 2, 1, 100); + auto & sprite2 = entity2.add_component<Sprite>( + s2, Color(0, 0, 0, 0), Sprite::FlipSettings{false, false}, 2, 1, 100); ASSERT_NE(sprite2.sprite_image.texture.get(), nullptr); EXPECT_EQ(sprite2.sorting_in_layer, 2); EXPECT_EQ(sprite2.order_in_layer, 1); - auto & sprite3 = entity3.add_component<Sprite>(s3, Color(0, 0, 0, 0), - Sprite::FlipSettings{false, false}, 1, 2, 100); + auto & sprite3 = entity3.add_component<Sprite>( + s3, Color(0, 0, 0, 0), Sprite::FlipSettings{false, false}, 1, 2, 100); ASSERT_NE(sprite3.sprite_image.texture.get(), nullptr); EXPECT_EQ(sprite3.sorting_in_layer, 1); EXPECT_EQ(sprite3.order_in_layer, 2); - auto & sprite4 = entity4.add_component<Sprite>(s4, Color(0, 0, 0, 0), - Sprite::FlipSettings{false, false}, 1, 1, 100); + auto & sprite4 = entity4.add_component<Sprite>( + s4, Color(0, 0, 0, 0), Sprite::FlipSettings{false, false}, 1, 1, 100); ASSERT_NE(sprite4.sprite_image.texture.get(), nullptr); EXPECT_EQ(sprite4.sorting_in_layer, 1); EXPECT_EQ(sprite4.order_in_layer, 1); @@ -66,7 +66,7 @@ TEST_F(RenderSystemTest, expected_throws) { EXPECT_ANY_THROW({ auto test = Texture(""); entity1.add_component<Sprite>(test, Color(0, 0, 0, 0), - Sprite::FlipSettings{false, false},1,1,100); + Sprite::FlipSettings{false, false}, 1, 1, 100); }); // No camera |