Breakout
Paddle.h
Go to the documentation of this file.
1 #ifndef PADDLE
2 #define PADDLE
3 #include "Vec2.h"
4 #include "Ball.h"
5 #include "Contact.h"
6 #include <SDL2/SDL.h>
7 #include "ResourceManager.h"
8 const int PADDLE_WIDTH = 150;
9 const int PADDLE_HEIGHT = 30;
10 const float PADDLE_SPEED = 1.0f;
15 class Paddle {
16 public:
23  Paddle(Vec2 position, Vec2 velocity, SDL_Renderer* renderer);
27  void Draw();
33  Contact checkCollision(Ball const& ball);
37  void Reset();
43  void Update(float dt, int WINDOW_WIDTH);
44 
49 
50 
51 private:
55  Vec2 position;
59  Vec2 defaultPosition;
63  SDL_Rect rect{};
67  Vec2 defaultVelocity;
71  SDL_Surface* spriteSheet;
75  SDL_Texture* texture;
79  SDL_Renderer* renderer;
84 
85 };
86 
87 #endif
const int PADDLE_HEIGHT
Definition: Paddle.h:9
const int PADDLE_WIDTH
Definition: Paddle.h:8
const float PADDLE_SPEED
Definition: Paddle.h:10
const int WINDOW_WIDTH
The Width of the game window.
Definition: Pong.cpp:20
Represents Ball in the game.
Definition: Ball.h:16
Represents Paddle in the game.
Definition: Paddle.h:15
Paddle(Vec2 position, Vec2 velocity, SDL_Renderer *renderer)
The constructor of the Paddle class that takes in initial position and velocity along with renderer a...
Definition: Paddle.cpp:3
void Update(float dt, int WINDOW_WIDTH)
This method will update the position of the paddle.
Definition: Paddle.cpp:33
Vec2 velocity
The velocity of the paddle.
Definition: Paddle.h:48
Contact checkCollision(Ball const &ball)
This Method checks the collision of Paddle with ball and returns where the ball hit the paddle.
Definition: Paddle.cpp:49
void Draw()
This Method helps the paddle to be rendered on the screen.
Definition: Paddle.cpp:26
void Reset()
This method will reset the padddle to it's inital position and velocity.
Definition: Paddle.cpp:127
The resource manager is responsible for handling and managing resources regarding the game.
Definition: ResourceManager.h:12
static ResourceManager & getInstance()
Method used to get instance of ResourceManager class.
Definition: ResourceManager.cpp:10
Vec2 will abstract X&Y position for ball and paddle.
Definition: Vec2.h:6
GLuint texture
Definition: glad.h:2396
Represents the contact when the ball hits paddle or wall.
Definition: Contact.h:21