-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.h
87 lines (75 loc) · 2.07 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
#ifndef GAME_H
#define GAME_H
#include "load_lib.h"
#include "console.h"
#include "event.h"
// Definitions
typedef enum {INTRO, NEWGAME, LEVEL, HELP, HIGHSCORE, CREDIT, INGAME} Scene;
typedef enum {EASY, MEDIUM, HARD} Level;
typedef enum {UP, DOWN, LEFT, RIGHT} Direction;
typedef enum {RED, GREEN, BLUE, YELLOW, CYAN, MAGENTA, WHITE, BLACK} Color;
typedef enum {PLAYER_1, PLAYER_2, TIE, UNKNOWN} ResultMatch;
typedef struct {
COORD head;
Direction direction;
int length;
int score;
} Snake;
typedef struct {
int buffer[65536];
COORD size;
} Map;
// Utilities
WORD changeForegroundColor(WORD attributes, Color code, int isIntensity);
int nextHeadSnake(Snake player, COORD *nextHead);
int nextRandom();
// Get status variables
Scene getCurrentScene();
int getFoodValue();
ResultMatch getResultMatch();
int getSpeedSnake();
int isExitGame();
int isGameOver();
int isHavingUncompletingGame();
int isPause();
// Set status variables
void setNewMap();
void setFood();
void setNewGame(int nPlayers, Level level);
void setGameOver(int winnerPlayer);
void setNextFrameInGame();
void saveUncompletingGame();
void changeBetweenPlayPause();
void changeDirectionSnake(int player, Direction newDirection);
void loadHighScore();
void saveHighScore(int newHighScore);
// Draw scenes
void drawIntro(CHAR_INFO buffer[]);
void drawNewGame(CHAR_INFO buffer[]);
void drawHelp(CHAR_INFO buffer[]);
void drawLevel(CHAR_INFO buffer[]);
void drawHighScore(CHAR_INFO buffer[]);
void drawCredit(CHAR_INFO buffer[]);
void drawInGame(CHAR_INFO buffer[]);
// Key event functions
void processKeyIntro(KEY_EVENT_RECORD event);
void processKeyNewGame(KEY_EVENT_RECORD event);
void processKeyHelp(KEY_EVENT_RECORD event);
void processKeyLevel(KEY_EVENT_RECORD event);
void processKeyHighScore(KEY_EVENT_RECORD event);
void processKeyCredit(KEY_EVENT_RECORD event);
void processKeyInGame(KEY_EVENT_RECORD event);
// Transfer scene
void toIntro();
void toContinue();
void toNewGame();
void toHelp();
void toLevel();
void toHighScore();
void toCredit();
void toInGame();
// Init game
void initGame();
// Run game
void runGame();
#endif