-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.h
57 lines (36 loc) · 1.13 KB
/
Game.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <SDL_ttf.h>
#include "Player.h"
#include "Ball.h"
class Game {
public:
Game();
~Game() = default;
int initialize();
void cleanup();
void handleEvents(SDL_Event &e);
void update();
void render();
void renderText();
int getPlayer1Score() const { return player1score; }
int getPlayer2Score() const { return player2score; }
void setPlayer1Score(int score) { player1score = score;
std::cout << "Player 1 score: " << player1score << std::endl;}
void setPlayer2Score(int score) { player2score = score;
std::cout << "Player 2 score: " << player2score << std::endl;}
bool isRunning;
static const int SCREEN_WIDTH = 800;
static const int SCREEN_HEIGHT = 640;
bool checkForPaddleCollision(SDL_Rect paddle);
void checkForWallCollision();
private:
SDL_Window *window;
SDL_Renderer *renderer;
Player player1 = Player(SCREEN_WIDTH, SCREEN_HEIGHT);
Player player2 = Player(SCREEN_WIDTH, SCREEN_HEIGHT);
SDL_Texture *textTexture;
TTF_Font *font;
SDL_Surface *textSurface;
SDL_Rect textRect;
int player1score;
int player2score;
};