37 lines
1 KiB
C++
37 lines
1 KiB
C++
#ifndef HOLESOME_SPRITE_SHEET_HPP
|
|
#define HOLESOME_SPRITE_SHEET_HPP
|
|
|
|
|
|
#include <memory>
|
|
#include <SFML/Graphics/Texture.hpp>
|
|
#include <SFML/Graphics/Sprite.hpp>
|
|
#include "animated_sprite.hpp"
|
|
#include "single_sprite.hpp"
|
|
|
|
class SpriteSheet
|
|
{
|
|
public:
|
|
SpriteSheet(const std::shared_ptr<sf::Texture>& texture, int columns, int rows);
|
|
|
|
[[nodiscard]] std::shared_ptr<SingleSprite> getSprite(int sequenceIndex) const;
|
|
|
|
[[nodiscard]] std::shared_ptr<AnimatedSprite> getAnimation(int startingSequenceIndex, int numberOfFrames) const;
|
|
|
|
[[nodiscard]] std::shared_ptr<sf::Texture> getTexture() const;
|
|
|
|
[[nodiscard]] sf::IntRect getTextureRect(int sequenceIndex) const;
|
|
|
|
[[nodiscard]] int getColumns() const;
|
|
[[nodiscard]] int getRows() const;
|
|
|
|
private:
|
|
int columns;
|
|
int rows;
|
|
std::shared_ptr<sf::Texture> texture;
|
|
std::vector<sf::Sprite> sprites;
|
|
|
|
[[nodiscard]] sf::Rect<int> getRect(int spriteWidth, int spriteHeight, int row, int column) const;
|
|
};
|
|
|
|
|
|
#endif //HOLESOME_SPRITE_SHEET_HPP
|