-
Notifications
You must be signed in to change notification settings - Fork 0
/
snakenode.cpp
39 lines (38 loc) · 913 Bytes
/
snakenode.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
#include "snakenode.h"
#include <QDebug>
#include <board.h>
snakeNode::snakeNode(QString imgpath,int xx,int yy)
{
img=imgpath;
QPixmap pix;
bool ret=pix.load(img);
if(!ret)
{
qDebug()<<"can not load the image";
return;
}
this->setFixedSize(20,20);
pix.scaled(20,20);
this->setStyleSheet("QLabel{border:0px;}");
this->setPixmap(pix);
xy_pos.x=xx;
xy_pos.y=yy;
this->move(xy_pos.x*20,xy_pos.y*20);
}
snakeNode::snakeNode(const snakeNode& othernode)
{
img=othernode.img;
QPixmap pix;
bool ret=pix.load(img);
if(!ret)
{
qDebug()<<"can not load the image";
return;
}
this->setFixedSize(20,20);
pix.scaled(20,20);
this->setStyleSheet("QLabel{border:0px;}");
this->setPixmap(pix);
xy_pos=othernode.xy_pos;
this->move(xy_pos.x*20,xy_pos.y*20);
}