-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboard.cpp
More file actions
67 lines (55 loc) · 1.23 KB
/
board.cpp
File metadata and controls
67 lines (55 loc) · 1.23 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
#include "board.h"
#include <QPainter>
#include <QImage>
#include <QPixmap>
#include <QDebug>
#include <map>
#include <string>
using namespace std;
board::board(QWidget* parent):QFrame(parent),p1(1,1,aP1ob),p2(9,9,aP2ob)
{
//merge
//qDebug()<<"angry"<<endl;
setFrameStyle(QFrame::Panel | QFrame::Sunken);
setFocusPolicy(Qt::StrongFocus);
cnt=0;
timer.start(200,this);
resize(1200,720);
initPlayer1();
initPlayer2();
}
QSize board::sizeHint() const
{
return QSize(1200,720);
}
QSize board::minimumSizeHint() const
{
return QSize(1200,720);
}
void board::initPlayer1()
{
int x=p1.getX(),y=p1.getY();
m.blockAt(x,y).addAbove(aPlayer1);
}
void board::initPlayer2()
{
int x=p2.getX(),y=p2.getY();
m.blockAt(x,y).addAbove(aPlayer2);
}
void board::countMapForDraw()
{
int x1=p1.getX(),y1=p1.getY(),
x2=p2.getX(),y2=p2.getY();
for(int i=1;i<=10;i++)
for(int j=1;j<=10;j++)
{
block& temp=m.blockAt(i,j);
if(i==x1 && j==y1) temp.addAbove(aPlayer1);
if(i==x2 && j==y2) temp.addAbove(aPlayer2);
mapForDraw[i][j]=temp.appearance();
}
}
bool board::inMap(int x,int y)
{
return x>=1 && x<=9 && y>=1 && y<=9;
}