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

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ InvisiblePower()

InvisiblePower::InvisiblePower ( int screen_width,
int screen_height )

Constructor for the InvisiblePower class.

Parameters
screen_widthThe width of the game screen
screen_heightThe height of the game screen

Initializes the star-shaped power at a random position

Parameters
screen_widthThe width of the game screen
screen_heightThe height of the game screen

Member Function Documentation

◆ render()

void InvisiblePower::render ( SDL_Renderer * renderer)
overridevirtual

Renders the power as a star on screen.

Renders the star-shaped power on screen.

Parameters
rendererSDL renderer for drawing

Draws a star shape using SDL rendering functions

Parameters
rendererSDL renderer for drawing

Reimplemented from Power.

◆ reset()

void InvisiblePower::reset ( int screen_width)
overridevirtual

Resets the power to a new random position.

Parameters
screen_widthThe width of the game screen

Reimplemented from Power.

◆ set_initialisation()

void InvisiblePower::set_initialisation ( bool init)

Sets the initialization flag.

Parameters
initThe initialization state to set

◆ update()

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.

Parameters
timeTime delta since last update
BallPointer to the ball object
rendererSDL renderer for drawing

Manages the star's movement, collision detection, and ball invisibility timing

Parameters
timeTime delta since last update
ballPointer to the ball object
rendererSDL renderer for drawing

Member Data Documentation

◆ initialisation

bool InvisiblePower::initialisation
private

Flag for first-time initialization

◆ repeat

float InvisiblePower::repeat
private

Timer for power-up respawn


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