-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpawn.cpp
More file actions
49 lines (41 loc) · 982 Bytes
/
Copy pathpawn.cpp
File metadata and controls
49 lines (41 loc) · 982 Bytes
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
#include "pawn.h"
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <iostream>
#include <QtWidgets>
#include <QColor>
#include <QGraphicsItem>
#include <QString>
#include <QSvgRenderer>
//Pawn::Pawn(){}
QRectF Pawn::boundingRect() const
{
return QRectF(x_, y_, width_, height_);
}
QPainterPath Pawn::shape() const
{
QPainterPath path;
path.addRect(x_, y_, width_, height_);
return path;
}
void Pawn::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(widget);
QRect tile = QRect(this->x_, this->y_, this->width_, this->height_);
if(color_ == "white"){
painter->drawImage(tile, QImage(":/assets/pawn_w.svg"));
}
else{
painter->drawImage(tile, QImage(":/assets/pawn_b.svg"));
}
}
QString Pawn::getType() {
return "pawn";
}
void Pawn::setMoved() {
moved_ = true;
}
bool Pawn::getMoved() {
return moved_;
}