Dualie
Loading...
Searching...
No Matches
Sprite.hpp
1//
2// Created by caleb on 7/28/24.
3//
4
5#ifndef DUALIE_SPRITE_HPP
6#define DUALIE_SPRITE_HPP
7#include <citro2d.h>
8#include <Dualie/Graphics/Transformable.hpp>
9#include <Dualie/Graphics/Drawable.hpp>
10#include <Dualie/Graphics/SpriteSheet.hpp>
11
12
13namespace dl
14{
15
19 class Sprite : public dl::Transformable, public dl::Drawable
20 {
21
22 C2D_Sprite m_sprite{};
23 float m_rotation{};
24 dl::Vector2f m_origin;
25
26 public:
27
28 Sprite();
29
35 void loadFromSpriteSheet(SpriteSheet spriteSheet, size_t index);
36
41 void setPosition(const dl::Vector2f &position) override;
42
47 void move(const dl::Vector2f &offset) override;
48
60 void setOrigin(const dl::Vector2f& origin);
61
69 void setOrigin(float x, float y);
70
75 void setRotation(const float &rotation);
76
80 const dl::Vector2f& getOrigin();
81
85 const float &getRotation();
86
91 void rotate(const float &rotationOffset);
92
93 void draw(const dl::Vector2f &viewOffset) override;
94
95 friend C2D_SpriteSheet SpriteSheet::getSpriteSheet();
96
97
98 };
99
100}
101
102
103#endif //DUALIE_SPRITE_HPP
The base class for any object that can be drawn to the screen.
Definition Drawable.hpp:15
A class used to load and contain t3x formatted spritesheets.
Definition SpriteSheet.hpp:17
A class used to handle the drawing and transformation of sprites.
Definition Sprite.hpp:20
void loadFromSpriteSheet(SpriteSheet spriteSheet, size_t index)
Loads an image into the sprite from a spritesheet.
Definition Sprite.cpp:51
void setOrigin(const dl::Vector2f &origin)
Sets the rotation of the sprite in radians.
Definition Sprite.cpp:56
void rotate(const float &rotationOffset)
Rotates the sprite on top of its current rotation.
Definition Sprite.cpp:30
const float & getRotation()
Definition Sprite.cpp:38
void setRotation(const float &rotation)
Sets the rotation of the sprite.
Definition Sprite.cpp:24
void setPosition(const dl::Vector2f &position) override
Sets the position of the sprite.
Definition Sprite.cpp:14
void move(const dl::Vector2f &offset) override
Moves the sprite offset number of pixels.
Definition Sprite.cpp:19
void draw(const dl::Vector2f &viewOffset) override
Draws the drawable to the screen.
Definition Sprite.cpp:44
const dl::Vector2f & getOrigin()
Definition Sprite.cpp:66
A base class for anything that has a position on the screen.
Definition Transformable.hpp:16