diff options
Diffstat (limited to '')
-rw-r--r-- | src/main/cpp/Map.cpp | 3 | ||||
-rw-r--r-- | src/main/cpp/Tile.cpp | 11 | ||||
-rw-r--r-- | src/main/headers/Tile.hpp | 11 |
3 files changed, 24 insertions, 1 deletions
diff --git a/src/main/cpp/Map.cpp b/src/main/cpp/Map.cpp index 6d3ee01..3cb1b9d 100644 --- a/src/main/cpp/Map.cpp +++ b/src/main/cpp/Map.cpp @@ -24,5 +24,6 @@ const std::vector<Tile>& Map::tiles() const bool Map::moveActor(Tile &from, Tile &to) { - // TODO + to.actor(from.actor()); + from.clearActor(); } diff --git a/src/main/cpp/Tile.cpp b/src/main/cpp/Tile.cpp new file mode 100644 index 0000000..9fc436a --- /dev/null +++ b/src/main/cpp/Tile.cpp @@ -0,0 +1,11 @@ +#include "Tile.hpp" + +bool Tile::actor(Actor *actor) +{ + if (_actor != nullptr) { + return false; + } + + _actor = actor; + return true; +} diff --git a/src/main/headers/Tile.hpp b/src/main/headers/Tile.hpp index 7292fde..919badc 100644 --- a/src/main/headers/Tile.hpp +++ b/src/main/headers/Tile.hpp @@ -1,6 +1,8 @@ #ifndef TILE_HPP #define TILE_HPP +#include "Actor.hpp" + struct Tile { enum Type @@ -12,6 +14,15 @@ struct Tile const int x, y; Tile(Type _type, int _x, int _y) : type(_type), x(_x), y(_y) {} + + Actor* actor() { return _actor; } + bool actor(Actor *actor); + + void clearActor() { _actor = nullptr; } + +private: + Actor *_actor = nullptr; + }; #endif |