summary refs log tree commit diff stats
path: root/src/map.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-02-18 12:35:45 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-02-18 12:35:45 -0500
commite16fb5be90c889c371cbb0ca2444735c2e12073c (patch)
treecbaa20e14a34c460b6c9886f266c4b4b6f62ae87 /src/map.h
parented08b673c50b076042d8f0c49501372168142764 (diff)
downloadtherapy-e16fb5be90c889c371cbb0ca2444735c2e12073c.tar.gz
therapy-e16fb5be90c889c371cbb0ca2444735c2e12073c.tar.bz2
therapy-e16fb5be90c889c371cbb0ca2444735c2e12073c.zip
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.
Diffstat (limited to 'src/map.h')
-rw-r--r--src/map.h70
1 files changed, 68 insertions, 2 deletions
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 @@
10class Map { 10class Map {
11public: 11public:
12 12
13 class Adjacent {
14 public:
15
16 enum class Type {
17 wall,
18 wrap,
19 warp,
20 reverse
21 };
22
23 Adjacent(
24 Type type = Type::wall,
25 int mapId = -1) :
26 type_(type),
27 mapId_(mapId)
28 {
29 }
30
31 inline Type getType() const
32 {
33 return type_;
34 }
35
36 inline int getMapId() const
37 {
38 return mapId_;
39 }
40
41 private:
42
43 Type type_;
44 int mapId_;
45 };
46
13 Map( 47 Map(
14 int id, 48 int id,
15 std::vector<int> tiles, 49 std::vector<int> tiles,
16 std::string title) : 50 std::string title,
51 Adjacent leftAdjacent,
52 Adjacent rightAdjacent,
53 Adjacent upAdjacent,
54 Adjacent downAdjacent) :
17 id_(id), 55 id_(id),
18 tiles_(std::move(tiles)), 56 tiles_(std::move(tiles)),
19 title_(std::move(title)) 57 title_(std::move(title)),
58 leftAdjacent_(std::move(leftAdjacent)),
59 rightAdjacent_(std::move(rightAdjacent)),
60 upAdjacent_(std::move(upAdjacent)),
61 downAdjacent_(std::move(downAdjacent))
20 { 62 {
21 } 63 }
22 64
@@ -35,11 +77,35 @@ public:
35 return title_; 77 return title_;
36 } 78 }
37 79
80 inline const Adjacent& getLeftAdjacent() const
81 {
82 return leftAdjacent_;
83 }
84
85 inline const Adjacent& getRightAdjacent() const
86 {
87 return rightAdjacent_;
88 }
89
90 inline const Adjacent& getUpAdjacent() const
91 {
92 return upAdjacent_;
93 }
94
95 inline const Adjacent& getDownAdjacent() const
96 {
97 return downAdjacent_;
98 }
99
38private: 100private:
39 101
40 int id_; 102 int id_;
41 std::vector<int> tiles_; 103 std::vector<int> tiles_;
42 std::string title_; 104 std::string title_;
105 Adjacent leftAdjacent_;
106 Adjacent rightAdjacent_;
107 Adjacent upAdjacent_;
108 Adjacent downAdjacent_;
43}; 109};
44 110
45#endif /* end of include guard: MAP_H_74055FC0 */ 111#endif /* end of include guard: MAP_H_74055FC0 */