-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.h
84 lines (64 loc) · 1.3 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef GAME_H
#define GAME_H
#include <SDL2/SDL.h>
#include <SDL2/SDL_mixer.h>
#include <string>
#include <cstdlib>
#include <iostream>
#include "entity/ball.h"
#include "entity/paddle.h"
#include "entity/block.h"
#include "utility/text.h"
static const int RANDOM_BLOCK_COLOR_SIZE = 7;
static const SDL_Color RANDOM_BLOCK_COLORS[] = {
{ 255, 0, 0, 255 },
{ 255, 94, 0, 255 },
{ 255, 191, 0, 255 },
{ 72, 255, 0, 255 },
{ 0, 26, 255, 255 },
{ 85, 0, 255, 255 },
{ 174, 0, 255, 255 }
};
class Game {
public:
Game(SDL_Renderer *_renderer);
void init();
void play();
void stop();
private:
void draw_entities();
void show_fps();
void show_timer();
void show_gameover();
void show_gameclear();
void display();
void clear();
void update();
void event_listener();
int fps_ticks;
int timer_ticks;
int timer;
bool is_show_fps;
float FPS;
int screen_width;
int screen_height;
bool key_left;
bool key_right;
bool is_play;
bool is_gameover;
SDL_Renderer *renderer;
SDL_Event event;
Ball ball;
Paddle paddle;
Block *blocks;
int block_size;
int block_count;
Text text;
Text text_bold;
Mix_Chunk *audio_block;
Mix_Chunk *audio_paddle;
Mix_Chunk *audio_start;
Mix_Music *audio_gameover;
Mix_Music *audio_gameclear;
};
#endif // GAME_H