-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.h
51 lines (33 loc) · 870 Bytes
/
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
#include <stdbool.h>
#include <unistd.h>
#include <time.h>
#include <string.h>
#include "SDL.h"
#include "player.h"
extern int SCREEN_WIDTH;
extern int SCREEN_HEIGHT;
extern int APPLE_COUNTER;
typedef struct {
SDL_Rect apple;
} Apple;
typedef struct {
SDL_Window *window;
SDL_Renderer *renderer;
int playerScore;
bool isRunning;
Player *player;
Apple apples[100];
} Game;
bool rectOverlap(SDL_Rect *rect, SDL_Rect *rect2);
void spawnApple(Apple *apple);
Uint32 spawnApplesTimer(Uint32 interval, void * param);
//Render
void renderApple(Apple *apple, SDL_Renderer *renderer);
void renderApples(Game *game);
void renderGame(Game *game);
//Game Util
int initializeGame(Game *game);
void cleanupGame(Game *game);
void handleGameEvents(Game *game, SDL_Event e);
void updateGame(Game *game);
void checkPlayerCollision(Game *game);