SUNENGINE 0.0.2
A simple and bright C++ game engine.
 
Loading...
Searching...
No Matches
SpriteString.h
1#ifndef SpriteString_H
2#define SpriteString_H
3
4#include <list>
5#include <string>
6class SpriteFont;
8using Glyph = SUNENGINESprite;
9
17class SpriteString
18{
19public:
20 SpriteString();
21 SpriteString(const SpriteString&) = delete;
22 SpriteString& operator=(const SpriteString&) = delete;
23 ~SpriteString() = default;
24
32 SpriteString(SpriteFont* font, std::string text, float x, float y);
33
38 float GetWidth();
39
44 float GetHeight();
45
51 void SetPosition(float x, float y);
52
57 float GetPosX() const;
58
63 float GetPosY() const;
64
72 void SetCollection(SpriteFont* font, std::string text, float x, float y);
73
81 void UpdateCollection(SpriteFont* font, std::string text, float x, float y);
82
89 void UpdateCollection(std::string text, float x, float y);
90
94 void Render();
95
101 void SetScaleFactor(float x, float y);
102
108 void SetScalePixel(float x, float y);
109
115 int GetLines() const;
116
121 float GetScaleX() const;
122
127 float GetScaleY() const;
128
133 void SetAngleDegrees(float degrees);
134
139 void SetAngleRadians(float radians);
140
146 void SetOrigin(float x, float y);
147
152 std::string GetText() const;
153
154private:
155
156 std::list<Glyph*> GlyphList;
157 using GlyphIt = std::list<Glyph*>::iterator;
158
160
161 float originX;
162 float originY;
163
164 float posX;
165 float posY;
166 int width;
167 int height;
168
169 float scaleX;
170 float scaleY;
171 int lines;
172 float angle;
173 std::string currentText;
174};
175
176#endif
Represents a sprite in the SUNENGINE.
Definition Sprites/SUNENGINESprite.h:16
Represents a font in the SUNENGINE.
Definition SpriteFont.h:19
float GetWidth()
Gets the width of the sprite string.
Definition SpriteString.cpp:13
float posY
The y-coordinate of the position.
Definition SpriteString.h:165
int width
The width of the sprite string.
Definition SpriteString.h:166
void SetOrigin(float x, float y)
Sets the origin of the sprite string.
Definition SpriteString.cpp:192
void UpdateCollection(SpriteFont *font, std::string text, float x, float y)
Updates the collection of sprites for the string.
Definition SpriteString.cpp:92
float GetScaleY() const
Gets the scale factor in the y direction.
Definition SpriteString.cpp:177
float GetScaleX() const
Gets the scale factor in the x direction.
Definition SpriteString.cpp:172
void SetScaleFactor(float x, float y)
Sets the scale factor for the sprite string.
Definition SpriteString.cpp:153
int GetLines() const
Sets the scale of the sprite string in pixels.
Definition SpriteString.cpp:167
void Render()
Renders the sprite string.
Definition SpriteString.cpp:107
float scaleX
The scale factor in the x direction.
Definition SpriteString.h:169
std::list< Glyph * >::iterator GlyphIt
Iterator type for the glyph list.
Definition SpriteString.h:157
float GetPosY() const
Gets the y-coordinate of the position.
Definition SpriteString.cpp:34
float GetHeight()
Gets the height of the sprite string.
Definition SpriteString.cpp:18
std::string GetText() const
Gets the current text of the sprite string.
Definition SpriteString.cpp:198
float originX
The x-coordinate of the origin.
Definition SpriteString.h:161
void SetAngleDegrees(float degrees)
Sets the angle of the sprite string in degrees.
Definition SpriteString.cpp:182
SpriteFont * pFont
Pointer to the SpriteFont used for rendering the string.
Definition SpriteString.h:159
float scaleY
The scale factor in the y direction.
Definition SpriteString.h:170
std::string currentText
The current text in the sprite string.
Definition SpriteString.h:173
void SetScalePixel(float x, float y)
Sets the scale of the sprite string in pixels.
Definition SpriteString.cpp:160
int height
The height of the sprite string.
Definition SpriteString.h:167
float originY
The y-coordinate of the origin.
Definition SpriteString.h:162
void SetPosition(float x, float y)
Sets the position of the sprite string.
Definition SpriteString.cpp:23
void SetCollection(SpriteFont *font, std::string text, float x, float y)
Sets the collection of sprites for the string.
Definition SpriteString.cpp:39
float angle
The angle of the sprite string in radians.
Definition SpriteString.h:172
std::list< Glyph * > GlyphList
List of glyphs representing the string.
Definition SpriteString.h:156
void SetAngleRadians(float radians)
Sets the angle of the sprite string in radians.
Definition SpriteString.cpp:187
float GetPosX() const
Gets the x-coordinate of the position.
Definition SpriteString.cpp:29
int lines
The number of lines in the sprite string.
Definition SpriteString.h:171
float posX
The x-coordinate of the position.
Definition SpriteString.h:164