![]() |
The NEW Pong Game V13.2.1
An interesting implemnettaion of the pong game
|
Represents a player paddle/racket in the game. More...
#include <paddle.hpp>
Public Member Functions | |
bool | get_inverse_power_active () const |
bool | get_is_left () const |
Checks if this is the left paddle. | |
float | get_pos_x () const |
Gets the paddle's x-coordinate. | |
float | get_pos_y () const |
Gets the paddle's y-coordinate. | |
float | get_racket_height () const |
Gets the paddle's height. | |
float | get_racket_speed () const |
Gets the paddle's movement speed. | |
float | get_racket_width () const |
Gets the paddle's width. | |
Paddle (int x, bool on_the_left_side) | |
Constructor for Paddle class. | |
SDL_Rect | rectangle () const |
Gets the paddle's SDL rectangle for collision detection. | |
void | render_object (SDL_Renderer *renderer) |
Renders the paddle on screen. | |
void | set_inverse_power_active (bool power_active) |
Sets the inverse_power_active boolean. | |
void | set_pos_x (float x) |
Sets the paddle's x-coordinate. | |
void | set_pos_y (float y) |
Sets the paddle's y-coordinate. | |
void | set_racket_height (float height) |
Sets the paddle's height. | |
void | update (float travel_time) |
Updates the paddle's position based on keyboard input. | |
Private Attributes | |
bool | inverse_power_active |
bool | is_left |
float | multiplier |
float | pos_x |
float | pos_y |
float | racket_height |
const float | racket_speed |
const float | racket_width |
Represents a player paddle/racket in the game.
This class handles the paddle's position, movement, rendering, and collision detection for the game.
Paddle::Paddle | ( | int | x, |
bool | on_the_left_side ) |
Constructor for Paddle class.
Constructing the Racket object for the game.
x | The initial x-coordinate position |
on_the_left_side | True if this paddle is on the left side, false if right |
x | Initial x-coordinate position |
on_the_left_side | True if this paddle is on the left side, false if right |
bool Paddle::get_inverse_power_active | ( | ) | const |
bool Paddle::get_is_left | ( | ) | const |
Checks if this is the left paddle.
float Paddle::get_pos_x | ( | ) | const |
Gets the paddle's x-coordinate.
float Paddle::get_pos_y | ( | ) | const |
Gets the paddle's y-coordinate.
float Paddle::get_racket_height | ( | ) | const |
Gets the paddle's height.
float Paddle::get_racket_speed | ( | ) | const |
Gets the paddle's movement speed.
float Paddle::get_racket_width | ( | ) | const |
Gets the paddle's width.
SDL_Rect Paddle::rectangle | ( | ) | const |
Gets the paddle's SDL rectangle for collision detection.
Getting the paddle's position on the screen on SDL.
void Paddle::render_object | ( | SDL_Renderer * | renderer | ) |
Renders the paddle on screen.
Drawing the paddle on the screen.
renderer | The SDL renderer to use for drawing |
void Paddle::set_inverse_power_active | ( | bool | power_active | ) |
Sets the inverse_power_active boolean.
power_active | Declaration of the state for the inverse_power_active boolean |
void Paddle::set_pos_x | ( | float | x | ) |
Sets the paddle's x-coordinate.
x | The new x position |
void Paddle::set_pos_y | ( | float | y | ) |
Sets the paddle's y-coordinate.
y | The new y position |
void Paddle::set_racket_height | ( | float | height | ) |
Sets the paddle's height.
height | The new height for the paddle |
void Paddle::update | ( | float | travel_time | ) |
Updates the paddle's position based on keyboard input.
Updating the paddle's position on the screen.
travel_time | Time delta since last update (in seconds) |
Lambda for moving the paddle
delta | Direction multiplier (-1 for up, 1 for down) |
time | Time delta for smooth movement |
Lambda for checking and adjusting paddle boundaries
|
private |
Whether this paddle is affected by the inverse power-up
|
private |
Whether this paddle is on the left side
|
private |
multiplier for the paddle's direction mouvement using the keyboard
|
private |
The paddle's x position
|
private |
The paddle's y position
|
private |
The paddle's height
|
private |
The paddle's movement speed (constant)
|
private |
The paddle's width (constant)