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

Classic circular ball implementation inheriting from BallBase. More...

#include <classic_ball.hpp>

+ Inheritance diagram for ClassicBall:

Public Member Functions

 ClassicBall ()
 Constructor for ClassicBall.
 
void render_object (SDL_Renderer *renderer) override
 Renders the classic ball on screen.
 
- Public Member Functions inherited from BallBase
 BallBase (float size=35.0f)
 Constructor for BallBase.
 
virtual SDL_Rect boundaries () const
 Gets the collision boundaries of the ball.
 
SDL_Color get_color () const
 Gets the color of the ball.
 
int get_game_mode () const
 
float get_pos_x () const
 Gets the x-coordinate of the ball.
 
float get_pos_y () const
 Gets the y-coordinate of the ball.
 
float get_vel_x () const
 Gets the x-velocity component of the ball.
 
float get_vel_y () const
 Gets the y-velocity component of the ball.
 
void random_direction_angle ()
 Randomizes the direction of the ball.
 
virtual void reset ()
 Resets the ball to the center of the screen.
 
void set_color (const SDL_Color &new_color)
 Sets the color of the ball.
 
void set_game_mode (int mode)
 
void set_position (float x, float y)
 Sets the position of the ball.
 
void set_velocity (float velX, float velY)
 Sets the velocity of the ball.
 
virtual void update (float travel_time, class Paddle *paddle1, class Paddle *paddle2, User *player1, User *player2)
 Updates the ball's position and handles collisions.
 
virtual ~BallBase ()
 Virtual destructor for proper cleanup in derived classes.
 

Private Attributes

SDL_Texture * ball_texture = nullptr
 

Additional Inherited Members

- Protected Attributes inherited from BallBase
const float ball_size
 
SDL_Color color
 
int game_mode = -1
 
float pos_x
 
float pos_y
 
float vel_x
 
float vel_y
 

Detailed Description

Classic circular ball implementation inheriting from BallBase.

This class implements a circular ball, the standard ball type in Pong, by overriding the render_object method from the base class.

Constructor & Destructor Documentation

◆ ClassicBall()

ClassicBall::ClassicBall ( )

Constructor for ClassicBall.

Initializes a classic circular ball with a default size of 15.0f

Member Function Documentation

◆ render_object()

void ClassicBall::render_object ( SDL_Renderer * renderer)
overridevirtual

Renders the classic ball on screen.

Overrides the base class method to render a circular shape using the circle_renderer function

Parameters
rendererThe SDL renderer to use for drawing

Uses the circle_renderer function to draw a circular shape at the ball's current position with the specified size and color

Parameters
rendererThe SDL renderer used for drawing

Implements BallBase.

Member Data Documentation

◆ ball_texture

SDL_Texture* ClassicBall::ball_texture = nullptr
private

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