Building Game Engines
Background.hpp
Go to the documentation of this file.
1 #ifndef BACKGROUND_HPP
2 #define BACKGROUND_HPP
3 
4 #include <SDL2/SDL.h>
5 #include <string>
6 
7 #include "Component.hpp"
8 #include "TransformComponent.hpp"
9 
13 class Background : public Component {
14  public:
19  Background(SDL_Texture* texture);
20 
24  ~Background();
25 
29  virtual void Update();
30 
34  virtual void Render(SDL_Renderer* renderer);
35 
36  private:
37  // Points to the texture of the background
38  SDL_Texture* m_texture;
39 
40  // Source and destination rectangles for rendering
41  SDL_Rect src, dest;
42 
43  // Offset tick interval
44  int ticks = 0;
45 
46  // Scrolling offset
47  int offset = 0;
48 };
49 
50 #endif
Definition: Background.hpp:13
virtual void Render(SDL_Renderer *renderer)
Definition: Background.cpp:19
virtual void Update()
Definition: Background.cpp:11
Definition: Component.hpp:10
~Background()
Definition: Background.cpp:7
Background(SDL_Texture *texture)
Definition: Background.cpp:3