-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyMap.cpp
More file actions
66 lines (60 loc) · 1.48 KB
/
myMap.cpp
File metadata and controls
66 lines (60 loc) · 1.48 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
#include "myMap.h"
myMap::myMap():
underMapForinit{
{},//第0行,因为数组从零开始,所以第0行和第0列都是0
// water 0 , house 1 , ground 2 , tree 3 ,bridge 4
{0,2,2,2,2,0,2,2,2,2},
{0,2,2,2,2,0,2,2,2,2},
{0,2,2,2,2,0,2,2,2,2},
{0,3,2,1,1,0,1,1,2,3},
{0,3,2,2,2,4,2,2,2,3},
{0,3,2,1,1,0,1,1,2,3},
{0,2,2,2,2,0,2,2,2,2},
{0,2,2,2,2,0,2,2,2,2},
{0,2,2,2,2,0,2,2,2,2} },
aboveMapForinit{
{},
// wood 7 , air 8 , bubble 9 , shoe 10 , drug 11
{0,8,8,7,8,8,8,7,8,8},
{0,8,7,8,8,8,8,8,7,8},
{0,7,8,8,8,8,8,8,8,7},
{0,8,8,8,8,8,8,8,8,8},
{0,8,8,8,8,8,8,8,8,8}, //第5行
{0,8,8,8,8,8,8,8,8,8},
{0,7,8,8,8,8,8,8,8,7},
{0,8,7,8,8,8,8,8,7,8},
{0,8,8,7,8,8,8,7,8,8} }//*/
{
intToBlock();
}
void myMap::intToBlock()
{
for(int i=1;i<=9;i++)
for(int j=1;j<=9;j++)
{
int tempu=underMapForinit[i][j],tempa=aboveMapForinit[i][j];
content[i][j].setUnder(uArray[tempu]);
content[i][j].addAbove(aArray[tempa]);
}
}
void myMap::moveAToB(int x1,int y1,int x2,int y2)
{
blockAt(x2,y2).addAbove(blockAt(x1,y1).getAbove());
blockAt(x1,y1).destroyAbove();
}
//缺少检测
void myMap::hideAToB(int x1,int y1,int x2,int y2)
{
blockAt(x2,y2).addAbove(blockAt(x1,y1).getAbove());
blockAt(x1,y1).destroyAbove();
}
//缺少检测
void myMap::cleanFlames()
{
for(int i=1;i<=9;i++)
for(int j=1;j<=9;j++)
{
if(content[i][j].haveFlame())
content[i][j].destroyAbove();
}
}