👔 Implement Tile

main
Alexis Drai 2 years ago
parent 8c04422f5d
commit 2a8a9d7150

@ -1,5 +1,6 @@
#include <iostream> #include <iostream>
#include "position/Position.h" #include "position/Position.h"
#include "tile/Tile.h"
using namespace std; using namespace std;
@ -24,5 +25,13 @@ int main()
cout << (p1 == p2) << endl; cout << (p1 == p2) << endl;
cout << (p1 != p2) << endl; cout << (p1 != p2) << endl;
auto t1 = Tile(p1, EMPTY);
cout << t1.pos() << " -- type: " << t1.getType() << " -- traversable?: " << t1.traversable() << endl;
auto t2 = Tile(p2, WALL);
cout << t2.pos() << " -- type: " << t2.getType() << " -- traversable?: " << t2.traversable() << endl;
return 0; return 0;
} }

@ -8,3 +8,18 @@ const Position &Tile::pos() const
{ {
return m_pos; return m_pos;
} }
Tile::Tile(Position pos, enum type type)
: m_pos(pos), m_type(type)
{}
type Tile::getType() const
{
return m_type;
}
bool Tile::traversable()
{
return m_type == 0; // EMPTY
}

@ -8,14 +8,28 @@
#include "../position/Position.h" #include "../position/Position.h"
enum type {
EMPTY,
WALL
};
class Tile class Tile
{ {
private: private:
Position m_pos; Position m_pos;
type m_type;
public: public:
explicit Tile(Position pos, type type);
const Position &pos() const; const Position &pos() const;
type getType() const;
bool traversable();
}; };
#endif //LABYRINTH_TILE_H #endif //LABYRINTH_TILE_H

Loading…
Cancel
Save