From e16fb5be90c889c371cbb0ca2444735c2e12073c Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 18 Feb 2018 12:35:45 -0500 Subject: Implemented map adjacency This brings along with it the ability to move to different maps, for which the PlayingSystem and PlayableComponent were introduced. The PlayingSystem is a general overseer system that handles big picture stuff like initializing the player and changing maps. The PlayableComponent represents the player. While the ControllableComponent is also likely to always only be on the player entity, the two are distinct by separation of concerns. This also required a refactoring of how collisions are processed, because of a bug where the player can move to a new map when horizontal collisions are checked, and vertical collisions are skipped, causing the player to clip through the ground because the normal force was never handled. --- src/map.h | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 2 deletions(-) (limited to 'src/map.h') diff --git a/src/map.h b/src/map.h index 9177870..6fe1e62 100644 --- a/src/map.h +++ b/src/map.h @@ -10,13 +10,55 @@ class Map { public: + class Adjacent { + public: + + enum class Type { + wall, + wrap, + warp, + reverse + }; + + Adjacent( + Type type = Type::wall, + int mapId = -1) : + type_(type), + mapId_(mapId) + { + } + + inline Type getType() const + { + return type_; + } + + inline int getMapId() const + { + return mapId_; + } + + private: + + Type type_; + int mapId_; + }; + Map( int id, std::vector tiles, - std::string title) : + std::string title, + Adjacent leftAdjacent, + Adjacent rightAdjacent, + Adjacent upAdjacent, + Adjacent downAdjacent) : id_(id), tiles_(std::move(tiles)), - title_(std::move(title)) + title_(std::move(title)), + leftAdjacent_(std::move(leftAdjacent)), + rightAdjacent_(std::move(rightAdjacent)), + upAdjacent_(std::move(upAdjacent)), + downAdjacent_(std::move(downAdjacent)) { } @@ -35,11 +77,35 @@ public: return title_; } + inline const Adjacent& getLeftAdjacent() const + { + return leftAdjacent_; + } + + inline const Adjacent& getRightAdjacent() const + { + return rightAdjacent_; + } + + inline const Adjacent& getUpAdjacent() const + { + return upAdjacent_; + } + + inline const Adjacent& getDownAdjacent() const + { + return downAdjacent_; + } + private: int id_; std::vector tiles_; std::string title_; + Adjacent leftAdjacent_; + Adjacent rightAdjacent_; + Adjacent upAdjacent_; + Adjacent downAdjacent_; }; #endif /* end of include guard: MAP_H_74055FC0 */ -- cgit 1.4.1