-
Notifications
You must be signed in to change notification settings - Fork 0
/
role.cpp
113 lines (97 loc) · 1.44 KB
/
role.cpp
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
#include "role.h"
Role::Role(void)
{
blood = 10000;
hield.freeRatio = 0;
hield.remain = 0;
satiety = 0;
toward = LEFT;
state = 0;
return;
}
Role::~Role(void)
{
return;
}
void Role::setBlood(short newBlood)
{
blood = newBlood;
return;
}
short Role::getBlood(void)
{
return blood;
}
void Role::setHield(Hield newHield)
{
hield = newHield;
return;
}
Hield Role::getHield(void)
{
return hield;
}
void Role::setSatiety(short newSatiety)
{
if (newSatiety >= 0 && newSatiety <= 10000) {
satiety = newSatiety;
}
return;
}
short Role::getSatiety(void)
{
return satiety;
}
void Role::setToward(short newToward)
{
toward = newToward;
return;
}
short Role::getToward(void)
{
return toward;
}
/* 判定角色是否活着 */
bool Role::isAlive(void)
{
return blood > 0;
}
/* 改变血量 */
void Role::changeBlood(short delta)
{
blood += delta;
if (blood < 0) {
blood = 0;
}
else if (blood > 10000) {
blood = 10000;
}
return;
}
static cv::Mat getRoleMat(unsigned short state)
{
static cv::Mat roleMats[] = {
cv::imread("pictures/role/role00000.png")
};
if (state < sizeof(roleMats) / sizeof(cv::Mat)) {
addAlpha(roleMats[state]);
return roleMats[state];
}
return getDefaultMat();
}
cv::Mat Role::getMat(void)
{
cv::Mat roleMat = getRoleMat(state).clone();
switch (toward) {
case 1:
case 3:
cv::rotate(roleMat, roleMat, toward - 1);
break;
case 2:
cv::flip(roleMat, roleMat, 1);
break;
default:
break;
}
return roleMat;
}