The NEW Pong Game V13.2.1
An interesting implemnettaion of the pong game
Loading...
Searching...
No Matches
letter.hpp
Go to the documentation of this file.
1
8#ifndef LETTER_HPP
9#define LETTER_HPP
10
11#include <SDL.h>
12#include <SDL_ttf.h>
13#include <vector>
14#include <string>
15
16#include "user.hpp"
17#include "macros.hpp"
18
27class Letter
28{
29private:
30 std::vector<std::string> words = {"Polytech", "Sorbonne", "2025"};
31 std::vector<char> lettersAtBottom;
32 std::string word;
35 char letter;
36 float x, y;
37 float speed;
38 SDL_Texture *texture;
40 SDL_Renderer *renderer;
41 TTF_Font *font;
43public:
53 Letter(int index, float startX, float startY, float velocity, SDL_Renderer *renderer, TTF_Font *font);
54
58 ~Letter();
59
70 void update_letter(float time, int screen_height, User *player1, User *player2, float ball_pos_x, float ball_pos_y, float ball_radius);
71
76 void render(SDL_Renderer *renderer);
77
85 bool collision_check(float ball_pos_x, float ball_pos_y, float ball_radius) const;
86
90 void next_letter();
91
95 void next_word();
96
101 void reset_word(int n);
102
107 float get_pos_x() const { return x; }
108
113 float get_pos_y() const { return y; }
114};
115
116#endif
Represents a letter in the storytime game mode.
Definition letter.hpp:28
TTF_Font * font
Definition letter.hpp:41
float get_pos_y() const
Gets the Y position of the letter.
Definition letter.hpp:113
std::vector< char > lettersAtBottom
Definition letter.hpp:31
float x
Definition letter.hpp:36
int width
Definition letter.hpp:39
std::string word
Definition letter.hpp:32
void next_letter()
Advances to the next letter in the current word.
Definition letter.cpp:63
float get_pos_x() const
Gets the X position of the letter.
Definition letter.hpp:107
int current_word_index
Definition letter.hpp:33
SDL_Texture * texture
Definition letter.hpp:38
std::vector< std::string > words
Definition letter.hpp:30
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.
Definition letter.cpp:96
float y
Definition letter.hpp:36
int height
Definition letter.hpp:39
void render(SDL_Renderer *renderer)
Renders the letter on screen.
Definition letter.cpp:140
bool collision_check(float ball_pos_x, float ball_pos_y, float ball_radius) const
Checks if the ball collides with the letter.
Definition letter.cpp:179
void next_word()
Advances to the next word in the words array.
Definition letter.cpp:170
float speed
Definition letter.hpp:37
~Letter()
Destructor for Letter class.
Definition letter.cpp:50
Letter(int index, float startX, float startY, float velocity, SDL_Renderer *renderer, TTF_Font *font)
Constructor for Letter class.
Definition letter.cpp:26
char letter
Definition letter.hpp:35
SDL_Renderer * renderer
Definition letter.hpp:40
void reset_word(int n)
Resets word and letter indices.
Definition letter.cpp:39
int current_letter_index
Definition letter.hpp:34
Represents a player in the game with name and score tracking.
Definition user.hpp:23
Defines macros and constants used throughout the project.
Header defining the User class for player management.