-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.cpp
60 lines (51 loc) · 1.28 KB
/
node.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
57
58
59
#include "node.h"
extern sf::Font font;
node::node()
{
static int num=-1;
num++;
tag=num;
text.setFont(font);
text.setFillColor(sf::Color::White);
text.setCharacterSize(18);
nodeshape.setRadius(25);
nodeshape.setFillColor(sf::Color::Blue);
nodeshape.setOutlineColor(sf::Color::Magenta);
nodeshape.setOutlineThickness(5);
}
void node::Create(int x, int y)
{
posx=x;
posy=y;
nodeshape.setPosition(x,y);
text.setPosition(x+35,y+35);
sf::FloatRect textRect = nodeshape.getLocalBounds();
text.setOrigin(textRect.left + textRect.width/2.0f,textRect.top + textRect.height/2.0f);
}
void node::Create(int x, int y, std::string a)
{
nodeshape.setPosition(x,y);
text.setPosition(x+52,y+35);
sf::FloatRect textRect = nodeshape.getLocalBounds();
text.setOrigin(textRect.left + textRect.width/2.0f,textRect.top + textRect.height/2.0f);
text.setString(a);
}
void node::setString(std::string str)
{
st=str;
text.setString(str);
}
sf::Vector2f node::getPosition()
{
return nodeshape.getPosition();
}
void node::Render(sf::RenderWindow* l_window)
{
l_window->draw(nodeshape);
l_window->draw(text);
}
void node::highlight()
{
nodeshape.setFillColor(sf::Color::Green);
text.setFillColor(sf::Color::Red);
}