![]() |
The NEW Pong Game V13.2.1
An interesting implemnettaion of the pong game
|
Class representing power-up items that affect gameplay. More...
#include <power.hpp>
Public Member Functions | |
bool | collision (BallBase *ball_type) const |
Checks for collision between the power and the ball. | |
Power (int screen_width, int screen_height) | |
Constructor for the Power class. | |
virtual void | render (SDL_Renderer *renderer) |
Renders the power on screen. | |
virtual void | reset (int screen_width) |
Resets the power-up to a new random position. | |
void | set_effect_is_active (bool active) |
void | set_is_active (bool active) |
Sets the active state of the power-up. | |
virtual void | update (float time, Paddle *racket1, Paddle *racket2, SDL_Renderer *renderer, BallBase *ball) |
Updates the power's position and effect. | |
Protected Attributes | |
SDL_Color | color |
float | duration_effect = 0.0f |
bool | effect_is_active = false |
int | height |
bool | is_active = false |
bool | play = true |
SDL_Texture * | power_texture = nullptr |
float | speed |
int | width |
float | x = 0 |
float | y = 0 |
Class representing power-up items that affect gameplay.
This class defines powerups that can be collected during gameplay to modify game elements like paddle size.
Power::Power | ( | int | screen_width, |
int | screen_height ) |
Constructor for the Power class.
screen_width | The width of the game screen |
screen_height | The height of the game screen |
Initializes the power with random size and position
screen_width | The width of the game screen |
screen_height | The height of the game screen |
bool Power::collision | ( | BallBase * | ball_type | ) | const |
Checks for collision between the power and the ball.
ball_type | The ball object |
ball_type | Pointer to the ball object |
|
virtual |
Renders the power on screen.
renderer | SDL renderer for drawing |
Draws a colored rectangle representing the power if it's active
renderer | SDL renderer for drawing |
Reimplemented in InversiblePower, and InvisiblePower.
|
virtual |
Resets the power-up to a new random position.
Resets the power to a new random position.
screen_width | The width of the game screen |
Reimplemented in InversiblePower, and InvisiblePower.
void Power::set_effect_is_active | ( | bool | active | ) |
void Power::set_is_active | ( | bool | active | ) |
Sets the active state of the power-up.
active | The new active state |
|
virtual |
Updates the power's position and effect.
Updates the power's position and checks for collision with the ball.
Virtual method that updates the game's parameters based on power effects
time | Time delta since last update |
racket1 | Pointer to first paddle |
racket2 | Pointer to second paddle |
ball_pos_x | Ball's X position |
ball_pos_y | Ball's Y position |
ball_radius | Ball's radius |
renderer | SDL renderer for drawing |
Handles power movement, collision detection, and effect application/duration
time | Time delta since last update |
racket1 | Pointer to first paddle |
racket2 | Pointer to second paddle |
ball | The ball object |
renderer | SDL renderer for drawing |
Reimplemented in InversiblePower.
|
protected |
Color of the power-up
|
protected |
Time remaining until effect ends
|
protected |
Whether the power's effect is currently active
|
protected |
Dimensions of the power-up
|
protected |
Used to determine if the power is currently visible and active
|
protected |
Flag to determine which player gets the effect. It is used only on power.cpp but not on the herited classes
|
protected |
Texture of the power-up as an image
|
protected |
Movement speed
|
protected |
|
protected |
X position of the power-up
|
protected |
Y position of the power-up