Dragonfly 4.19
A text-based game engine
Path.h
1//
2// Path.h - A path class.
3//
4
5#ifndef __PATH_H__
6#define __PATH_H__
7
8// System includes.
9#include <vector>
10
11// Engine includes.
12#include "Color.h"
13#include "Vector.h"
14
15namespace df {
16
17class Path {
18
19 private:
20 std::vector<Vector> m_path; ///< Nodes in path.
21 int m_index; ///< Index of next target node.
22
23 public:
24 Path();
25
26 /// Return next node in path.
27 /// Return (-1,-1) if none.
29
30 /// Return previous node in path.
31 /// Return (-1,-1) if none.
33
34 /// Set path.
35 void setPath(std::vector<Vector> new_path);
36
37 /// Return path.
38 std::vector<Vector> getPath() const;
39
40 /// Return true when at end of path.
41 bool endOfPath() const;
42
43 /// Return last node of path.
44 Vector getEnd() const;
45
46 /// Set index of path.
47 /// Return 0 if ok, else -1;
48 int setIndex(int new_index);
49
50 /// Return index of path.
51 int getIndex() const;
52
53 /// Draw remaining path in indicated color.
54 /// Return 0 if ok, negative if not.
55 int draw(Color color) const;
56
57 /// Increment path target node.
58 /// If at last node, index stays at end.
60};
61
62} // end of namespace df
63
64#endif // __PATH_H__
Definition: Path.h:17
Vector nextNode() const
Return next node in path.
int m_index
Index of next target node.
Definition: Path.h:21
int getIndex() const
Return index of path.
int setIndex(int new_index)
Set index of path.
std::vector< Vector > m_path
Nodes in path.
Definition: Path.h:20
Vector previousNode() const
Return previous node in path.
Vector getEnd() const
Return last node of path.
bool endOfPath() const
Return true when at end of path.
std::vector< Vector > getPath() const
Return path.
void setPath(std::vector< Vector > new_path)
Set path.
int draw(Color color) const
Draw remaining path in indicated color.
Path operator++(int)
Increment path target node.
Definition: Vector.h:12
An animation for a sprite.
Definition: Animation.h:15
Color
Colors Dragonfly recognizes.
Definition: Color.h:11