-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrass.cpp
42 lines (38 loc) · 810 Bytes
/
grass.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
#include "grass.h"
#include"globalconfig.h"
#include<QDebug>
Grass::Grass()
{
row=0;
col=0;
x=-1;
y=-1;
width=0;
height=0;
}
Grass::Grass(int r,int c,bool able)
{
row=r;
col=c;
x=grasscolpos[c-1];
y=grassrowpos[r-1];
width=grasscolpos[c]-grasscolpos[c-1];
height=grassrowpos[r]-grassrowpos[r-1];
qDebug()<<row<<" "<<col<<" "<<x<<""<<y<<" "<<width<<" "<<height;
plant=NULL;
iffree=true;
ifput=able;
}
void Grass::mousePressEvent(QMouseEvent* ev)
{
if(ev->button()==Qt::LeftButton)
{
QString str =QString("you have press the grass at row= %1 col=%2").arg(row).arg(col);
qDebug()<<str;
emit this->leftclick(row,col);
}
else if(ev->button()==Qt::RightButton)
{
emit this->rightclick();
}
}