-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgamestate.c
67 lines (51 loc) · 978 Bytes
/
gamestate.c
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
#include "gamestate.h"
#include <stdlib.h>
#include <string.h>
static struct {
int health;
int isGameCleared;
int isLevelCleared;
int hasLost;
char currentLevelName[100];
} gData;
void resetGameState() {
resetHealth();
gData.isLevelCleared = 0;
gData.isGameCleared = 0;
gData.hasLost = 0;
}
void resetLevelState() {
gData.isLevelCleared = 0;
gData.hasLost = 0;
}
int hasClearedLevel() {
return gData.isLevelCleared;
}
void setLevelCleared(int remainingHealth) {
gData.isLevelCleared = 1;
gData.health = remainingHealth;
}
int hasClearedGame() {
return gData.isGameCleared;
}
void setGameCleared() {
gData.isGameCleared = 1;
}
int hasLost() {
return gData.hasLost;
}
void setLost() {
gData.hasLost = 1;
}
void resetHealth() {
gData.health = 1000;
}
int getRemainingHealth(){
return gData.health;
}
void setCurrentLevelName(char* name) {
strcpy(gData.currentLevelName, name);
}
char* getCurrentLevelName() {
return gData.currentLevelName;
}