-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmapseg.cpp
98 lines (81 loc) · 1.95 KB
/
mapseg.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
#include "mapseg.h"
#include<QImage>
//mapSegNum=7
int mapSeg::lifes[mapSegNum]={0,400,100000,0,0,0,100};
bool mapSeg::penetration_1[mapSegNum]={true,false,false,true,false,true,false};
bool mapSeg::penetration_2[mapSegNum]={true,false,false,true,true,true,false};
mapSeg::mapSeg(int i,int j)
{
this->pos.setX(SegWidth*j);
this->pos.setY(SegHeight*i);
this->calSphere();
this->disappear=false;
this->kind=0;
this->life=lifes[this->kind];
this->penetration1=penetration_1[this->kind];
this->penetration2=penetration_2[this->kind];
}
void mapSeg::modifyMapSeg(int i, int j)
{
this->pos.setX(SegWidth*j);
this->pos.setY(SegHeight*i);
this->calSphere();
this->disappear=false;
this->life=lifes[this->kind];
this->penetration1=penetration_1[this->kind];
this->penetration2=penetration_2[this->kind];
}
void mapSeg::display(QPainter &paint)
{
if(this->isDisappeared())
return;
switch(this->kind)
{
case 0:
break;
case 1:
paint.drawImage(rectSphere,glb.images[0]);
break;
case 2:
paint.drawImage(rectSphere,glb.images[1]);
break;
case 3:
paint.drawImage(rectSphere,glb.images[2]);
break;
case 4:
paint.drawImage(rectSphere,glb.images[3]);
break;
case 5:
paint.drawImage(rectSphere,glb.images[4]);
break;
default:
break;
}
}
int mapSeg::getKind()const
{
return this->kind;
}
void mapSeg::calSphere()
{
this->rectSphere.setRect(pos.x(),pos.y(),
SegWidth,SegHeight);
}
void mapSeg::beAttacked(int attack)
{
if(life>0)
life-=attack;
if(life<=0)
{
this->disappear=true;
life=0;
}
}
bool mapSeg::isPenetration1()const
{
return penetration1;
}
bool mapSeg::isPenetration2()const
{
return penetration2;
}