![]() |
The NEW Pong Game V13.2.1
An interesting implemnettaion of the pong game
|
Power-up that makes the ball temporarily invisible. More...
#include <invisible_power.hpp>
Inheritance diagram for InvisiblePower:Public Member Functions | |
| InvisiblePower (int screen_width, int screen_height) | |
| Constructor for the InvisiblePower class. | |
| void | render (SDL_Renderer *renderer) override |
| Renders the power as a star on screen. | |
| void | reset (int screen_width) override |
| Resets the power to a new random position. | |
| void | set_initialisation (bool init) |
| Sets the initialization flag. | |
| void | update (float time, BallBase *Ball, SDL_Renderer *renderer) |
| Updates the power's position and the ball's visibility. | |
Public Member Functions inherited from Power | |
| 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. | |
| virtual void | update (float time, Paddle *racket1, Paddle *racket2, SDL_Renderer *renderer, BallBase *ball) |
| Updates the power's position and effect. | |
Private Attributes | |
| bool | initialisation |
| float | repeat |
Additional Inherited Members | |
Protected Attributes inherited from Power | |
| 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 makes the ball temporarily invisible.
This class implements a special star-shaped power-up that, when collected, makes the ball invisible for a period of time.
| InvisiblePower::InvisiblePower | ( | int | screen_width, |
| int | screen_height ) |
Constructor for the InvisiblePower class.
| screen_width | The width of the game screen |
| screen_height | The height of the game screen |
Initializes the star-shaped power at a random position
| screen_width | The width of the game screen |
| screen_height | The height of the game screen |
|
overridevirtual |
Renders the power as a star on screen.
Renders the star-shaped power on screen.
| renderer | SDL renderer for drawing |
Draws a star shape using SDL rendering functions
| renderer | SDL renderer for drawing |
Reimplemented from Power.
|
overridevirtual |
Resets the power to a new random position.
| screen_width | The width of the game screen |
Reimplemented from Power.
| void InvisiblePower::set_initialisation | ( | bool | init | ) |
Sets the initialization flag.
| init | The initialization state to set |
| void InvisiblePower::update | ( | float | time, |
| BallBase * | ball, | ||
| SDL_Renderer * | renderer ) |
Updates the power's position and the ball's visibility.
Updates the power's position and handles ball visibility effects.
| time | Time delta since last update |
| Ball | Pointer to the ball object |
| renderer | SDL renderer for drawing |
Manages the star's movement, collision detection, and ball invisibility timing
| time | Time delta since last update |
| ball | Pointer to the ball object |
| renderer | SDL renderer for drawing |
|
private |
Flag for first-time initialization
|
private |
Timer for power-up respawn