-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgame.h
131 lines (108 loc) · 2.44 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#ifndef __GAME__
#define __GAME__
class Timer;
struct Robeman;
struct Particle;
class Game {
private:
bool started;
bool running;
bool paused;
bool quit;
// main game screen
SDL_Surface *screen;
// game camera
SDL_Rect camera;
// event catcher
SDL_Event event;
int eventCounter;
// ressources
Mix_Music *music;
Mix_Chunk *sound1; // jump
Mix_Chunk *sound2; // achieve
Mix_Chunk *sound3; // hurt
Mix_Chunk *sound4; // collect
Mix_Chunk *sound5; // shoot
Mix_Chunk *sound6; // explode
SDL_Surface *image;
SDL_Surface *background;
SDL_Surface *menu;
SDL_Rect bgBox;
// font
TTF_Font *font;
// player
SDL_Rect playerRect[ 9 ];
int playerX;
int playerY;
int playerVelX;
int playerVelY;
int playerSprite;
int playerMovement; // actually PLAYER_MOVEMENT
Timer playerAnimationTimer;
Timer playerInvincibleTimer;
bool playerFalling;
bool playerJumping;
bool playerInvincible;
int playerJumpStartY;
int playerScore;
int playerHealth;
std::vector<Particle> bullets;
// world
SDL_Rect worldTiles[ 29 ];
int *worldMap; // array of tiles that build the world
int worldWidth; // in tiles
int worldHeight; // in tiles
bool gameIsLight;
int gameDifficulty;
int collectibleNuns;
bool gameWin;
bool gameLost;
bool gameMenu;
int selectedMenu;
bool gameShowInfo;
Timer infoTimer;
// robemen - enemies
std::vector<Robeman> robemen;
// particles
std::vector<Particle> particles;
// DEBUG
Timer fps;
Timer drawTimer;
int draws;
int frame;
float frameRate;
public:
Game( );
~Game( );
void buildWorldMap( );
void initialize( );
void initialize( int );
void run( );
void destroy( );
void showMenu( );
void shoot( );
void handleEvent( );
void update( Uint32 );
void updatePlayerMovement( float );
void updatePlayerAnimation( float );
void updatePlayerBullets( float );
void updateCamera( float );
void updateRobemen( float );
void updateParticles( float );
void draw( );
void drawPlayer( );
void drawWorld( );
void drawDebug( );
void drawRobemen( );
void drawParticles( );
void drawStats( );
void drawMessage( int );
void drawMenu( );
void switchDarkWorld( );
SDL_Surface *load_image( std::string );
void drawThat( int, int, SDL_Surface *, SDL_Rect * );
// helper
SDL_Rect helper_get_rect_for_image( int );
SDL_Rect helper_get_rect_for_images( int, int, int );
};
#endif