SDL SPOOKY PLATFORMER ENGINE  0.2.0
An implementation of a platformer using sdl, implemented using an entity component system and efficient collision management.
SpriteComponent.hpp
Go to the documentation of this file.
1 #ifndef SPRITE_H
2 #define SPRITE_H
3 
4 #include <string>
5 
6 #include "Component.hpp"
7 #include "GameObject.hpp"
8 #include "TransformComponent.hpp"
9 #include "ResourceManager.hpp"
10 #include "PhysicsComponent.hpp"
11 
17 class SpriteComponent : public Component
18 {
19 public:
23  SpriteComponent(std::shared_ptr<Sprite> s, int maxFrames, int width, int height);
28 
32  void Update(float deltaTime);
33 
37  void Render(SDL_Renderer *ren);
38 
39  unsigned int m_currentFrame{0};
40 
41 private:
42  int m_maxFrames;
43  int m_height;
44  int m_width;
45  int m_maxHeight;
46  int m_maxWidth;
47  std::shared_ptr<Sprite> m_sprite;
48  PhysicsComponent* physics;
49 
50  // An SDL Surface contains pixel data to draw an image
51 
52  SDL_Rect m_src;
53  SDL_Rect m_dest;
54 };
55 
56 #endif
Definition: PhysicsComponent.hpp:8
void Render(SDL_Renderer *ren)
Definition: SpriteComponent.cpp:47
void Update(float deltaTime)
Definition: SpriteComponent.cpp:18
unsigned int m_currentFrame
Definition: SpriteComponent.hpp:39
~SpriteComponent()
Definition: SpriteComponent.cpp:14
SpriteComponent(std::shared_ptr< Sprite > s, int maxFrames, int width, int height)
Definition: SpriteComponent.cpp:5
Definition: Component.hpp:13
Definition: SpriteComponent.hpp:17