-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgraph_EatableItem.cpp
executable file
·57 lines (43 loc) · 1.45 KB
/
graph_EatableItem.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <QPainter>
#include "Settings.h"
#include "graph_EatableItem.h"
#include "h_EatableItem.h"
const int zoom = 1;
//////////////////////////////////////////
// graph_EatableItem
//////////////////////////////////////////
graph_EatableItem::graph_EatableItem(Settings* settings, graph_Simulation *aGraph_Sim, h_EatableItem* anItem)
: graph_Item(settings, aGraph_Sim),
item(anItem),
width(5*zoom),
color(200, 100, 100)
{
transferPositionFrom(item);
QObject::connect(item, SIGNAL(positionChanged(h_Item*)),
this, SLOT(refreshPosition(h_Item*)));
}
QRectF graph_EatableItem::boundingRect() const
{
return QRectF(-width, -width, width*2, width*2);
}
void graph_EatableItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
painter->setBrush(color);
painter->drawEllipse(-width, -width, width*2, width*2);
}
//////////////////////////////////////////
// graph_Food
//////////////////////////////////////////
graph_Food::graph_Food(Settings* settings, graph_Simulation *aGraph_Sim, h_EatableItem* anItem)
: graph_EatableItem(settings, aGraph_Sim, anItem)
{
color.setRgb(100, 200, 100);
}
//////////////////////////////////////////
// graph_Poison
//////////////////////////////////////////
graph_Poison::graph_Poison(Settings* settings, graph_Simulation *aGraph_Sim, h_EatableItem* anItem)
: graph_EatableItem(settings, aGraph_Sim, anItem)
{
color.setRgb(200, 100, 100);
}