Game Engine 2D Platformer
ScoreDisplayComponent.hpp
Go to the documentation of this file.
1 /*
2  * @file ScoreDisplayComponent.hpp
3  * @brief ScoreDisplayComponent class interface
4  * @date 2021-03-12
5  ***********************************************/
6 #ifndef SCOREDISPLAYCOMPONENT_HPP
7 #define SCOREDISPLAYCOMPONENT_HPP
8 
9 #include "Component.hpp"
10 #include <map>
11 #include <math.h>
12 #include <string>
13 #include <memory>
14 #include <iterator>
15 #include <SDL2_image/SDL_image.h>
16 #include <SDL2_ttf/SDL_ttf.h>
17 #include <SDL2/SDL.h>
18 #include "Constants.hpp"
19 #include "ResourceManager.hpp"
20 
24 {
25 public:
29  ScoreDisplayComponent(SDL_Renderer* ren);
36  void StartUp();
39  void ShutDown();
43  void Update(GameEntity& entity);
47  void Render(GameEntity &entity);
48  SDL_Rect rect1;
49  SDL_Rect rect2;
50  SDL_Rect backgroundRect;
51 
52 private:
53  SDL_Renderer *renderer;
54  TTF_Font *scoreFont;
55  SDL_Color colorCode={0,0,0};
56 
57  SDL_Surface *scoreWordSurface;
58  SDL_Texture *scoreWordTexture;
59 
60  SDL_Surface *scoreSurface;
61  SDL_Texture *scoreTexture;
62  //Create a ResourceManager instance
64 };
65 
66 #endif
The interface class for different components to inherit.
Definition: Component.hpp:16
Represents an interactable entity in the game that includes Main Character, NPC, Tiles ,...
Definition: GameEntity.hpp:22
The resource manager is responsible for handling and managing resources regarding the game.
Definition: ResourceManager.hpp:23
static ResourceManager & getInstance()
Method used to get instance of ResourceManager class.
Definition: ResourceManager.cpp:8
ScoreDisplayComponent class used to show a GameEntity's score.
Definition: ScoreDisplayComponent.hpp:24
~ScoreDisplayComponent()
Destructor for ScoreDisplayComponent.
Definition: ScoreDisplayComponent.cpp:40
SDL_Rect rect1
Definition: ScoreDisplayComponent.hpp:48
void ShutDown()
Destroys and frees attributes for ScoreDisplayComponent.
Definition: ScoreDisplayComponent.cpp:48
SDL_Rect backgroundRect
Definition: ScoreDisplayComponent.hpp:50
SDL_Rect rect2
Definition: ScoreDisplayComponent.hpp:49
void Update(GameEntity &entity)
Updates the ScoreDisplayComponent.
Definition: ScoreDisplayComponent.cpp:65
ScoreDisplayComponent(SDL_Renderer *ren)
Constuctor for ScoreDisplayComponent.
Definition: ScoreDisplayComponent.cpp:8
void StartUp()
Initializes the attributes for ScoreDisplayComponent.
Definition: ScoreDisplayComponent.cpp:44
void Render(GameEntity &entity)
Renders the ScoreDisplayComponent.
Definition: ScoreDisplayComponent.cpp:55