-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.cpp
More file actions
67 lines (59 loc) · 1.02 KB
/
Copy pathNode.cpp
File metadata and controls
67 lines (59 loc) · 1.02 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "Node.h"
Node::Node(int x, int y)
{
_tile.setSize(sf::Vector2f(24, 24));
_tile.setPosition(sf::Vector2f(x * 24, y * 24));
_tile.setOutlineThickness(2);
_tile.setOutlineColor(sf::Color::Cyan);
_tile.setFillColor(sf::Color::Black);
_wall = 0;
}
int Node::getNodeType() const
{
return _wall;
}
bool Node::getVisited() const
{
return _visited;
}
int Node::getParent(int i) const
{
return _parent[i];
}
void Node::setNodeType(const int type)
{
_wall = type;
if (_wall == 2)
_visited = 1;
}
void Node::setVisited(const bool visited)
{
_visited = visited;
}
void Node::setParent(const int x, const int y)
{
_parent[0] = x;
_parent[1] = y;
}
void Node::draw(sf::RenderWindow &window)
{
switch (_wall)
{
case 0:
_tile.setFillColor(sf::Color::Black);
break;
case 1:
_tile.setFillColor(sf::Color::White);
break;
case 2:
_tile.setFillColor(sf::Color::Green);
break;
case 3:
_tile.setFillColor(sf::Color::Red);
break;
case 4:
_tile.setFillColor(sf::Color::Yellow);
break;
}
window.draw(_tile);
}