The NEW Pong Game V13.2.1
An interesting implemnettaion of the pong game
Loading...
Searching...
No Matches
Paddle Class Reference

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
 

Detailed Description

Represents a player paddle/racket in the game.

This class handles the paddle's position, movement, rendering, and collision detection for the game.

Constructor & Destructor Documentation

◆ Paddle()

Paddle::Paddle ( int x,
bool on_the_left_side )

Constructor for Paddle class.

Constructing the Racket object for the game.

Parameters
xThe initial x-coordinate position
on_the_left_sideTrue if this paddle is on the left side, false if right
xInitial x-coordinate position
on_the_left_sideTrue if this paddle is on the left side, false if right

Member Function Documentation

◆ get_inverse_power_active()

bool Paddle::get_inverse_power_active ( ) const

◆ get_is_left()

bool Paddle::get_is_left ( ) const

Checks if this is the left paddle.

Returns
True if this is the left paddle, false if right

◆ get_pos_x()

float Paddle::get_pos_x ( ) const

Gets the paddle's x-coordinate.

Returns
The paddle's x position

◆ get_pos_y()

float Paddle::get_pos_y ( ) const

Gets the paddle's y-coordinate.

Returns
The paddle's y position

◆ get_racket_height()

float Paddle::get_racket_height ( ) const

Gets the paddle's height.

Returns
The height of the paddle

◆ get_racket_speed()

float Paddle::get_racket_speed ( ) const

Gets the paddle's movement speed.

Returns
The paddle's speed value

◆ get_racket_width()

float Paddle::get_racket_width ( ) const

Gets the paddle's width.

Returns
The width of the paddle

◆ rectangle()

SDL_Rect Paddle::rectangle ( ) const

Gets the paddle's SDL rectangle for collision detection.

Getting the paddle's position on the screen on SDL.

Returns
SDL_Rect representing the paddle's position and dimensions

◆ render_object()

void Paddle::render_object ( SDL_Renderer * renderer)

Renders the paddle on screen.

Drawing the paddle on the screen.

Parameters
rendererThe SDL renderer to use for drawing

◆ set_inverse_power_active()

void Paddle::set_inverse_power_active ( bool power_active)

Sets the inverse_power_active boolean.

Parameters
power_activeDeclaration of the state for the inverse_power_active boolean

◆ set_pos_x()

void Paddle::set_pos_x ( float x)

Sets the paddle's x-coordinate.

Parameters
xThe new x position

◆ set_pos_y()

void Paddle::set_pos_y ( float y)

Sets the paddle's y-coordinate.

Parameters
yThe new y position

◆ set_racket_height()

void Paddle::set_racket_height ( float height)

Sets the paddle's height.

Parameters
heightThe new height for the paddle

◆ update()

void Paddle::update ( float travel_time)

Updates the paddle's position based on keyboard input.

Updating the paddle's position on the screen.

Parameters
travel_timeTime delta since last update (in seconds)

Lambda for moving the paddle

Parameters
deltaDirection multiplier (-1 for up, 1 for down)
timeTime delta for smooth movement

Lambda for checking and adjusting paddle boundaries

Member Data Documentation

◆ inverse_power_active

bool Paddle::inverse_power_active
private

Whether this paddle is affected by the inverse power-up

◆ is_left

bool Paddle::is_left
private

Whether this paddle is on the left side

◆ multiplier

float Paddle::multiplier
private

multiplier for the paddle's direction mouvement using the keyboard

◆ pos_x

float Paddle::pos_x
private

The paddle's x position

◆ pos_y

float Paddle::pos_y
private

The paddle's y position

◆ racket_height

float Paddle::racket_height
private

The paddle's height

◆ racket_speed

const float Paddle::racket_speed
private

The paddle's movement speed (constant)

◆ racket_width

const float Paddle::racket_width
private

The paddle's width (constant)


The documentation for this class was generated from the following files: