![]() |
The NEW Pong Game V13.2.1
An interesting implemnettaion of the pong game
|
Power-up that inverts paddle controls temporarily. More...
#include <inverse_power.hpp>
Public Member Functions | |
InversiblePower (int screen_width, int screen_height) | |
Constructor for InversiblePower. | |
void | render (SDL_Renderer *renderer) override |
Renders the power-up on screen. | |
void | reset (int screen_width) override |
Resets the power-up position. | |
void | update (float time, Paddle *racket1, Paddle *racket2, SDL_Renderer *renderer, BallBase *ball) override |
Updates the power-up state. | |
![]() | |
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. | |
void | set_effect_is_active (bool active) |
void | set_is_active (bool active) |
Sets the active state of the power-up. | |
Private Attributes | |
bool | inverse_paddle = false |
float | repeat |
Additional Inherited Members | |
![]() | |
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 |
Power-up that inverts paddle controls temporarily.
This power-up appears as an arrow on screen. When a player hits it with the ball, that player's paddle controls are inverted (up becomes down and vice versa) for a short period of time.
InversiblePower::InversiblePower | ( | int | screen_width, |
int | screen_height ) |
Constructor for InversiblePower.
Constructs an InversiblePower object.
screen_width | Width of the game screen |
screen_height | Height of the game screen |
screen_width | Width of the game screen |
screen_height | Height of the game screen |
Initializes the power-up and sets it to active state.
|
overridevirtual |
Renders the power-up on screen.
Renders the power-up on screen as an arrow.
renderer | SDL renderer to draw the power-up |
Draws the power-up as a red arrow pointing downward when active. The arrow indicates that this power-up has a negative effect.
renderer | SDL renderer to draw the power-up |
Reimplemented from Power.
|
overridevirtual |
Resets the power-up position.
Resets the power-up to a new random position.
screen_width | Width of the game screen for positioning |
Places the power-up at a random horizontal position at the top of the screen and assigns it a random color.
screen_width | Width of the game screen for positioning |
Reimplemented from Power.
|
overridevirtual |
Updates the power-up state.
Updates the power-up's state based on game events.
time | Delta time since last update |
racket1 | Pointer to the first paddle |
racket2 | Pointer to the second paddle |
renderer | SDL renderer to draw effects |
ball | Pointer to the game ball |
Handles the power-up movement, collision detection with the ball, activation of control inversion effect, and timing for effect duration. When the ball collides with this power-up, the controls for the player who last hit the ball are inverted for 3 seconds.
time | Delta time since last frame |
racket1 | First player's paddle |
racket2 | Second player's paddle |
renderer | SDL renderer (unused in this method) |
ball | The game ball for collision detection |
Reimplemented from Power.
|
private |
Whether the power is currently active for a specific paddle
|
private |
Timer for power-up respawn