Game Engine 2D Platformer
AIGraphicsComponent.hpp
Go to the documentation of this file.
1 /*
2  * @file GraphicsComponent.hpp
3  * @brief GraphicsComponent class interface
4  * @date 2021-03-12
5  ***********************************************/
6 #ifndef AIGRAPHICSCOMPONENT_HPP
7 #define AIGRAPHICSCOMPONENT_HPP
8 
9 #include "Component.hpp"
10 #include <map>
11 #include <math.h>
12 #include "ResourceManager.hpp"
13 #include <string>
14 #include <memory>
15 #include <iterator>
16 #include <SDL2_image/SDL_image.h>
17 
21 {
22 public:
27  AIGraphicsComponent(SDL_Renderer* ren);
35  void StartUp();
39  void ShutDown();
44  void Update(GameEntity& entity);
49  void Render(GameEntity& entity);
53  void LoadImage(std::string filepath, SDL_Renderer *ren);
54 
55 private:
56  SDL_Renderer *renderer;
57  SDL_Rect src, dest;
58  SDL_Surface *m_spritesheet;
59  SDL_Texture *m_texture;
60  std::map<int, std::vector<int>> map;
61 
62  int frameStart;
63  int frameEnd;
64  int frame = 0;
65  int widthImg, heightImg, row, col, tempWidth, tempHeight;
66  int tileHeight, tileWidth;
67  //Create a ResourceManager instance
69 };
70 
71 #endif
GraphicsComponent class used to flip through frames for a GameEntity.
Definition: AIGraphicsComponent.hpp:21
void ShutDown()
Shutdown function to destroy and free attributes of AIGraphicsComponent.
Definition: AIGraphicsComponent.cpp:25
void Update(GameEntity &entity)
Updates the attributes of AIGraphicsComponent.
Definition: AIGraphicsComponent.cpp:40
void LoadImage(std::string filepath, SDL_Renderer *ren)
Loads image to use for graphics.
Definition: AIGraphicsComponent.cpp:73
AIGraphicsComponent(SDL_Renderer *ren)
Constructor of AIGraphicsComponent.
Definition: AIGraphicsComponent.cpp:8
void StartUp()
StartUp function to Initialize attributes of AIGraphicsComponent.
Definition: AIGraphicsComponent.cpp:21
~AIGraphicsComponent()
Destructor of AIGraphicsComponent.
Definition: AIGraphicsComponent.cpp:17
void Render(GameEntity &entity)
Helps Render the AI Entity of AIGraphicsComponent.
Definition: AIGraphicsComponent.cpp:32
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