Skip to content

Commit

Permalink
update SpriteBatch to v1.1
Browse files Browse the repository at this point in the history
updates Sprite Batch to v1.1, which changes the rotation type to sf::Angle - instead of float - to match sf::Sprite.
  • Loading branch information
Hapaxia committed Feb 20, 2025
1 parent dcec345 commit 67aee52
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
18 changes: 18 additions & 0 deletions changelogs/SpriteBatch.md
Original file line number Diff line number Diff line change
@@ -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
12 changes: 6 additions & 6 deletions src/SelbaWard/SpriteBatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down
8 changes: 4 additions & 4 deletions src/SelbaWard/SpriteBatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand All @@ -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

Expand Down

0 comments on commit 67aee52

Please sign in to comment.