![]() |
The NEW Pong Game V13.2.1
An interesting implemnettaion of the pong game
|
Represents a letter in the storytime game mode. More...
#include <letter.hpp>
Public Member Functions | |
bool | collision_check (float ball_pos_x, float ball_pos_y, float ball_radius) const |
Checks if the ball collides with the letter. | |
float | get_pos_x () const |
Gets the X position of the letter. | |
float | get_pos_y () const |
Gets the Y position of the letter. | |
Letter (int index, float startX, float startY, float velocity, SDL_Renderer *renderer, TTF_Font *font) | |
Constructor for Letter class. | |
void | next_letter () |
Advances to the next letter in the current word. | |
void | next_word () |
Advances to the next word in the words array. | |
void | render (SDL_Renderer *renderer) |
Renders the letter on screen. | |
void | reset_word (int n) |
Resets word and letter indices. | |
void | update_letter (float time, int screen_height, User *player1, User *player2, float ball_pos_x, float ball_pos_y, float ball_radius) |
Updates the letter position and checks for collisions. | |
~Letter () | |
Destructor for Letter class. | |
Private Attributes | |
int | current_letter_index |
int | current_word_index |
TTF_Font * | font |
int | height |
char | letter |
std::vector< char > | lettersAtBottom |
SDL_Renderer * | renderer |
float | speed |
SDL_Texture * | texture |
int | width |
std::string | word |
std::vector< std::string > | words = {"Polytech", "Sorbonne", "2025"} |
float | x |
float | y |
Represents a letter in the storytime game mode.
This class handles the display and interaction of letters that move across the screen in the story mode. Players can collect these letters by hitting them with the ball.
Letter::Letter | ( | int | index, |
float | startX, | ||
float | startY, | ||
float | velocity, | ||
SDL_Renderer * | renderer, | ||
TTF_Font * | font ) |
Constructor for Letter class.
index | Initial index for word and letter selection |
startX | Starting X position |
startY | Starting Y position |
velocity | Movement speed |
renderer | SDL renderer to use |
font | TTF font to use |
Initializes a letter with position, speed, and selects the initial word and letter
index | Initial index for word and letter selection |
startX | Starting X position |
startY | Starting Y position |
velocity | Movement speed |
renderer | SDL renderer to use |
font | TTF font to use |
Letter::~Letter | ( | ) |
Destructor for Letter class.
Cleans up the texture resource
bool Letter::collision_check | ( | float | ball_pos_x, |
float | ball_pos_y, | ||
float | ball_radius ) const |
Checks if the ball collides with the letter.
ball_pos_x | Ball's X position |
ball_pos_y | Ball's Y position |
ball_radius | Ball's radius |
float Letter::get_pos_x | ( | ) | const |
Gets the X position of the letter.
float Letter::get_pos_y | ( | ) | const |
Gets the Y position of the letter.
void Letter::next_letter | ( | ) |
Advances to the next letter in the current word.
Creates a new texture for the next letter or moves to next word if needed
void Letter::next_word | ( | ) |
Advances to the next word in the words array.
void Letter::render | ( | SDL_Renderer * | renderer | ) |
Renders the letter on screen.
renderer | SDL renderer to use for drawing |
void Letter::reset_word | ( | int | n | ) |
Resets word and letter indices.
n | New index to set |
void Letter::update_letter | ( | float | time, |
int | screen_height, | ||
User * | player1, | ||
User * | player2, | ||
float | ball_pos_x, | ||
float | ball_pos_y, | ||
float | ball_radius ) |
Updates the letter position and checks for collisions.
time | Time delta since last update |
screen_height | Window height for boundary checking |
player1 | Pointer to first player |
player2 | Pointer to second player |
ball_pos_x | Ball's X position |
ball_pos_y | Ball's Y position |
ball_radius | Ball's radius |
|
private |
Index of current letter in the current word
|
private |
Index of current word in the words array
|
private |
TTF font for rendering text
|
private |
Dimensions of the letter texture
|
private |
Current letter being displayed
|
private |
Letters collected at the bottom of screen
|
private |
SDL renderer reference
|
private |
Movement speed of the letter
|
private |
Texture for rendering the letter
|
private |
|
private |
Current word being displayed
|
private |
Words to display letter by letter
|
private |
|
private |
Position of the letter