From 67aee521e1544c7069b5dd07749339dccc16d965 Mon Sep 17 00:00:00 2001 From: Hapaxia Date: Thu, 20 Feb 2025 09:09:26 +0000 Subject: [PATCH] update SpriteBatch to v1.1 updates Sprite Batch to v1.1, which changes the rotation type to sf::Angle - instead of float - to match sf::Sprite. --- changelogs/SpriteBatch.md | 18 ++++++++++++++++++ src/SelbaWard/SpriteBatch.cpp | 12 ++++++------ src/SelbaWard/SpriteBatch.hpp | 8 ++++---- 3 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 changelogs/SpriteBatch.md diff --git a/changelogs/SpriteBatch.md b/changelogs/SpriteBatch.md new file mode 100644 index 0000000..d931838 --- /dev/null +++ b/changelogs/SpriteBatch.md @@ -0,0 +1,18 @@ +# Sprite Batch Change Log +All notable changes to this project will be documented in this file. + +## [1.1.0] - 2025-02-20 +### Changed +- Rotation values are now sf::Angle instead of float, similar to sf::Sprite + +## [1.01] - 2025-01-23 +### Fixed +- Update to work with SFML 3 + +## [1.0.0] - 2024-11-23 +### Added +- Full version + +[1.1.0]: +[1.0.1]: https://github.com/Hapaxia/SelbaWard/commit/7fd0b32c8f40627b5f5ee1b9e327ce6a419a4ec3 +[1.0.0]: https://github.com/Hapaxia/SelbaWard/commit/12544088bfc9de8559e97583b2fa07b02bd4d808 diff --git a/src/SelbaWard/SpriteBatch.cpp b/src/SelbaWard/SpriteBatch.cpp index dfe781c..01034a2 100644 --- a/src/SelbaWard/SpriteBatch.cpp +++ b/src/SelbaWard/SpriteBatch.cpp @@ -245,10 +245,10 @@ void SpriteBatch::move(const std::size_t index, const sf::Vector2f offset) m_sprites[index].isUpdateRequired = true; } -void SpriteBatch::rotate(const std::size_t index, const float angle) +void SpriteBatch::rotate(const std::size_t index, const sf::Angle angle) { priv_testIsIndexValid(index); - m_sprites[index].sprite.rotate(sf::degrees(angle)); + m_sprites[index].sprite.rotate(angle); m_sprites[index].isUpdateRequired = true; } @@ -276,10 +276,10 @@ sf::Vector2f SpriteBatch::getOrigin(const std::size_t index) const return m_sprites[index].sprite.getOrigin(); } -float SpriteBatch::getRotation(const std::size_t index) const +sf::Angle SpriteBatch::getRotation(const std::size_t index) const { priv_testIsIndexValid(index); - return m_sprites[index].sprite.getRotation().asDegrees(); + return m_sprites[index].sprite.getRotation(); } sf::Vector2f SpriteBatch::getScale(const std::size_t index) const @@ -331,10 +331,10 @@ void SpriteBatch::move(const sf::Vector2f offset) m_isGlobalUpdateRequired = true; } -void SpriteBatch::rotate(const float angle) +void SpriteBatch::rotate(const sf::Angle angle) { for (auto& sprite : m_sprites) - sprite.sprite.rotate(sf::degrees(angle)); + sprite.sprite.rotate(angle); m_isGlobalUpdateRequired = true; } diff --git a/src/SelbaWard/SpriteBatch.hpp b/src/SelbaWard/SpriteBatch.hpp index b21b6ca..83e4a6f 100644 --- a/src/SelbaWard/SpriteBatch.hpp +++ b/src/SelbaWard/SpriteBatch.hpp @@ -50,7 +50,7 @@ const sf::Texture sfmlEmptyTexture{}; namespace selbaward { -// Sprite Batch v1.0.1 +// Sprite Batch v1.1.0 class SpriteBatch : public sf::Drawable { public: @@ -102,14 +102,14 @@ class SpriteBatch : public sf::Drawable // setters - relative void move(std::size_t index, sf::Vector2f offset); - void rotate(std::size_t index, float angle); + void rotate(std::size_t index, sf::Angle angle); void scale(std::size_t index, sf::Vector2f factor); void scale(std::size_t index, float factor); // scales both x and y by the same factor // getters (that match the setters) sf::Vector2f getPosition(std::size_t index) const; sf::Vector2f getOrigin(std::size_t index) const; - float getRotation(std::size_t index) const; + sf::Angle getRotation(std::size_t index) const; sf::Vector2f getScale(std::size_t index) const; sf::IntRect getTextureRect(std::size_t index) const; sf::Color getColor(std::size_t index) const; @@ -124,7 +124,7 @@ class SpriteBatch : public sf::Drawable // global sprite methods (affects all sprites) - relative void move(sf::Vector2f offset); - void rotate(float angle); + void rotate(sf::Angle angle); void scale(sf::Vector2f factor); void scale(float factor); // scales both x and y by the same factor