-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.cpp
More file actions
44 lines (32 loc) · 1.03 KB
/
Copy pathnode.cpp
File metadata and controls
44 lines (32 loc) · 1.03 KB
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
#include <SFML/Graphics.hpp>
#include "node.hpp"
Node::Node(const float& nodeSize, const sf::Vector2f& mouse_position)
: circle(nodeSize){
circle.setOrigin({nodeSize, nodeSize});
circle.setPosition(mouse_position);
circle.setFillColor({178, 102, 255});
}
Node::Node(){}
void Node::addNeighbour(Node* neighbour){
for(Node* node : adjacencyList){
if (node == neighbour){
return;
}
}
adjacencyList.emplace_back(neighbour);
}
const std::vector<Node*>& Node::getAdjacencyList(){
return adjacencyList;
}
bool Node::contains(sf::Vector2f mouse_position){
return circle.getGlobalBounds().contains(mouse_position);
}
sf::Vector2f Node::getPosition(){
return circle.getPosition();
}
void Node::changeColor(sf::Color color){
circle.setFillColor(color);
}
void Node::draw(sf::RenderTarget& target, sf::RenderStates states) const{
target.draw(circle, states);
}