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

Triangle shaped ball implementation inheriting from BallBase. More...

#include <triangle_ball.hpp>

+ Inheritance diagram for TriangleBall:

Public Member Functions

void render_object (SDL_Renderer *renderer) override
 Renders the triangle ball on screen.
 
 TriangleBall ()
 Constructor for TriangleBall.
 
- 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.
 

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

Triangle shaped ball implementation inheriting from BallBase.

This class implements a triangle-shaped ball for the game by overriding the render_object method from the base class.

Constructor & Destructor Documentation

◆ TriangleBall()

TriangleBall::TriangleBall ( )

Constructor for TriangleBall.

Initializes a triangle ball with a default size of 20.0f

Member Function Documentation

◆ render_object()

void TriangleBall::render_object ( SDL_Renderer * renderer)
overridevirtual

Renders the triangle ball on screen.

Overrides the base class method to render a triangle shape using the triangle_renderer function

Parameters
rendererThe SDL renderer to use for drawing

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

Parameters
rendererThe SDL renderer used for drawing

Implements BallBase.


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