Building Game Engines
Sprite.hpp
Go to the documentation of this file.
1 #ifndef SPRITE_HPP
2 #define SPRITE_HPP
3 
4 #include <string>
5 
7 #include "Component.hpp"
8 #include "TransformComponent.hpp"
9 
13 class Sprite : public Component {
14  public:
21  Sprite(SDL_Texture* texture, TransformComponent* transform, int img_w, int img_h);
22 
26  ~Sprite();
27 
31  virtual void Update();
32 
36  virtual void Render(SDL_Renderer* ren);
37 
38  private:
39  // Points to the transform of the game object this component is attached to
40  TransformComponent* transform;
41 
42  // The current frame of this sprite
43  unsigned int m_currentFrame;
44 
45  // Points to the texture of the spritesheet
46  SDL_Texture* m_texture;
47 
48  // Source and destination rectangles for rendering
49  SDL_Rect m_src, m_dest;
50 };
51 
52 #endif
Sprite(SDL_Texture *texture, TransformComponent *transform, int img_w, int img_h)
Definition: Sprite.cpp:3
Definition: Sprite.hpp:13
~Sprite()
Definition: Sprite.cpp:11
Definition: TransformComponent.hpp:9
Definition: Component.hpp:10
virtual void Render(SDL_Renderer *ren)
Definition: Sprite.cpp:33
virtual void Update()
Definition: Sprite.cpp:15