-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboss.cpp
More file actions
161 lines (134 loc) · 2.82 KB
/
boss.cpp
File metadata and controls
161 lines (134 loc) · 2.82 KB
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#include "boss.h"
#include<QTimer>
#include<pcscene.h>
#include<QDebug>
#define jingzhi_1 ":/new/resources/jingzhi1.png"
#define jingzhi_2 ":/new/resources/jingzhi2.png"
#define jingzhi_3 ":/new/resources/jingzhi3.png"
#define jingzhi_4 ":/new/resources/jingzhi4.png"
#define pugong_1 ":/new/resources/pugong1.png"
#define pugong_2 ":/new/resources/pugong2.png"
#define jineng_11 ":/new/resources/qishoushi.png"
#define jineng_12 ":/new/resources/jineng1.png"
#define jineng_21 ":/new/resources/qishoushi.png"
#define jineng_22 ":/new/resources/jineng2.png"
static int boss_ac=0;
Boss::Boss()
{
action.setInterval(300);
do_action.setInterval(5000);
ji_action.setInterval(100);
x=1030;
y=160;
wid=340;
hei=500;
hp=10000;
maxhp=10000;
jingzhi_=1;
pugong_=0;
jineng1_=0;
jineng2_=0;
live=0;
//加载图片
for(int i=0;i<4;i++)
{
jingzhi[i].load(QString(":/new/resources/jingzhi%1.png").arg(i+1));
}
for(int i=0;i<2;i++)
{
pugong[i].load(QString(":/new/resources/pugong%1.png").arg(i+1));
}
for(int i=0;i<2;i++)
{
jineng1[i].load(QString(":/new/resources/jineng1%1.png").arg(i+1));
}
for(int i=0;i<2;i++)
{
jineng2[i].load(QString(":/new/resources/jineng2%1.png").arg(i+1));
}
curjing=0;
curpu=0;
curji1=0;
curji2=0;
connect(&action,&QTimer::timeout,
[=]()
{
if(jingzhi_)
{
curjing=(curjing+1)%4;
}
else if(pugong_)
{
curpu++;
curpu=curpu%2;
}
else if(jineng1_)
{
curji1=(curji1+1)%2;
}
else if(jineng2_)
{
curji2=(curji2+1)%2;
}
}
);
hpp_Timer.setInterval(20); //设定每帧时长
connect(&hpp_Timer,&QTimer::timeout,
[=]()
{
if(hp<maxhp)
{
hp+=10 ;
}
}
);
}
void Boss::reducehp()
{
hp-=200;
}
int Boss::getbaifenzhihp()
{
return this->hp*100/this->maxhp;
}
QPixmap Boss::getpic()
{
QPixmap pic;
/* if(boss_ac==30)
{
boss_ac=0;
jingzhi_=1;
pugong_=0;
jineng1_=0;
jineng2_=0;
}
*/
if(jingzhi_)
{
//qDebug()<<"w";
pic=jingzhi[curjing];
}
else if(pugong_)
{
//qDebug()<<"ww";
boss_ac++;
pic=pugong[curpu];
}
else if(jineng1_)
{
//qDebug()<<"www";
boss_ac++;
pic=jineng1[curji1];
}
else if(jineng2_)
{
//qDebug()<<"wwww";
boss_ac++;
pic=jineng2[curji2];
}
return pic;
}
void Boss::die()
{
if(this->hp<=0)live=0;
}