Breakout
Breakout
GameObject.hpp
1 #ifndef GAME_OBJECT_HPP
2 #define GAME_OBJECT_HPP
3 
4 #include <SDL2/SDL.h>
5 
10 class GameObject {
11  public:
13  GameObject(
14  int posX,
16  int posY,
18  int width,
20  int height);
21 
23  virtual void Update() = 0;
24 
26  virtual void Render(SDL_Renderer* ren) = 0;
27 
32  int getPosX() const;
33 
38  int getPosY() const;
39 
44  int getScaleW() const;
45 
50  int getScaleH() const;
51 
55  void Disable();
56 
58  void Enable();
59 
64  bool IsActive() const;
65 
66  protected:
67 
69  int x;
70 
72  int y;
73 
75  int scaleW;
76 
78  int scaleH;
79 
81  bool active;
82 };
83 
84 #endif
int getPosX() const
Gets the x position of this GameObject.
Definition: GameObject.cpp:6
void Enable()
Enables this GameObject.
Definition: GameObject.cpp:16
int x
The x coordinate of the center of this GameObject.
Definition: GameObject.hpp:69
bool IsActive() const
Gets whether this GameObject is active.
Definition: GameObject.cpp:18
int scaleW
The total width of this GameObject.
Definition: GameObject.hpp:75
virtual void Update()=0
Updates this GameObject.
GameObject(int posX, int posY, int width, int height)
Constructs a GameObject.
Definition: GameObject.cpp:3
A GameObject class.
Definition: GameObject.hpp:10
int getScaleH() const
Gets the total height of this GameObject.
Definition: GameObject.cpp:12
int y
The x coordinate of the center of this GameObject.
Definition: GameObject.hpp:72
bool active
Whether or not this GameObject is active.
Definition: GameObject.hpp:81
virtual void Render(SDL_Renderer *ren)=0
Renders this GameObject.
int getPosY() const
Gets the y position of this GameObject.
Definition: GameObject.cpp:8
int scaleH
The total height of this GameObject.
Definition: GameObject.hpp:78
int getScaleW() const
Gets the total width of this GameObject.
Definition: GameObject.cpp:10
void Disable()
Disables this GameObject.
Definition: GameObject.cpp:14