![]() |
The NEW Pong Game V13.2.1
An interesting implemnettaion of the pong game
|
Square shaped ball implementation inheriting from BallBase. More...
#include <square_ball.hpp>
Inheritance diagram for SquareBall:Public Member Functions | |
| void | render_object (SDL_Renderer *renderer) override |
| Renders the square ball on screen. | |
| SquareBall () | |
| Constructor for SquareBall. | |
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 |
Square shaped ball implementation inheriting from BallBase.
This class implements a square-shaped ball for the game by overriding the render_object method from the base class.
| SquareBall::SquareBall | ( | ) |
Constructor for SquareBall.
Initializes a square ball with a default size of 20.0f
|
overridevirtual |
Renders the square ball on screen.
Overrides the base class method to render a square shape using the square_renderer function
| renderer | The SDL renderer to use for drawing |
Uses the square_renderer function to draw a square shape at the ball's current position with the specified size and color
| renderer | The SDL renderer used for drawing |
Implements BallBase.