Level H Engine
Text.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <SDL.h>
4 #include <SDL_ttf.h>
5 #include <string>
6 #include "Sprite.h"
7 #include "../Maths/Vec2.h"
8 
12 class Text
13 {
14 public:
20  Text(std::string text, std::string fontLocation);
21 
28  Text(std::string text, std::string fontLocation, int fontSize);
29 
38  Text(std::string text, std::string fontLocation, int r, int g, int b);
39 
46  Text(std::string text, std::string fontLocation, SDL_Colour fontColour);
47 
57  Text(std::string text, std::string fontLocation, int fontSize, int r, int g, int b);
58 
66  Text(std::string text, std::string fontLocation, int fontSize, SDL_Colour fontColour);
67 
71  ~Text();
72 
77  void pushToScreen(Vec2 pos);
78 
85  void setColour(int r, int g, int b);
86 
91  void setColour(SDL_Colour colour);
92 
97  void setFontSize(int inSize);
98 
103  void setFont(std::string inFontLocation);
104 
109  void setText(std::string inText);
110 
116 
117 private:
119  TTF_Font* font;
121  SDL_Colour fontColour;
125  int fontSize;
127  std::string text, fontLocation;
130 
134  void createTextTexture();
135 };
Creates a Text sprite for use with using the Text formating.
Definition: Text.h:12
void setText(std::string inText)
Sets the text.
Definition: Text.cpp:144
Contains the Vec2 structure with functions and overloaded operators.
Definition: Vec2.h:8
void setColour(int r, int g, int b)
Sets the colour of the text.
Definition: Text.cpp:97
std::string fontLocation
Definition: Text.h:127
void setFont(std::string inFontLocation)
Sets the font of the text.
Definition: Text.cpp:131
Text(std::string text, std::string fontLocation)
Constructs the Text Texture. Font size and colour will be default (size 10 and black).
Definition: Text.cpp:3
~Text()
Destructs the Text Texture.
Definition: Text.cpp:82
Vec2 getDimensions()
Gets the dimensions of the Text Texture.
Definition: Text.cpp:153
void createTextTexture()
Creates a Text Texture using the Text data.
Definition: Text.cpp:158
Creates a Sprite for use with 2D.
Definition: Sprite.h:11
Vec2 dimensions
The Texture dimensions.
Definition: Text.h:129
int fontSize
Font size.
Definition: Text.h:125
std::string text
The text and font location.
Definition: Text.h:127
TTF_Font * font
Font.
Definition: Text.h:119
void setFontSize(int inSize)
Sets the font size of the text.
Definition: Text.cpp:115
Sprite * surfaceData
The surface sprite.
Definition: Text.h:123
SDL_Colour fontColour
Font colour.
Definition: Text.h:121
void pushToScreen(Vec2 pos)
Pushes the Text Texture to the screen to the XY Coordinates.
Definition: Text.cpp:91