diff options
-rw-r--r-- | res/maps/map1.tmx | 5 | ||||
-rw-r--r-- | src/main.cpp | 2 | ||||
-rw-r--r-- | src/map.cpp | 6 | ||||
-rw-r--r-- | src/map.h | 4 |
4 files changed, 15 insertions, 2 deletions
diff --git a/res/maps/map1.tmx b/res/maps/map1.tmx index 6ad312b..d830158 100644 --- a/res/maps/map1.tmx +++ b/res/maps/map1.tmx | |||
@@ -1,5 +1,5 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="48" height="32" tilewidth="16" tileheight="16" infinite="0" nextlayerid="4" nextobjectid="5"> | 2 | <map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="48" height="32" tilewidth="16" tileheight="16" infinite="0" nextlayerid="4" nextobjectid="6"> |
3 | <tileset firstgid="1" name="fromRom" tilewidth="16" tileheight="16" tilecount="240" columns="10"> | 3 | <tileset firstgid="1" name="fromRom" tilewidth="16" tileheight="16" tilecount="240" columns="10"> |
4 | <image source="map1_tiles.png" width="160" height="384"/> | 4 | <image source="map1_tiles.png" width="160" height="384"/> |
5 | <tile id="77"> | 5 | <tile id="77"> |
@@ -771,6 +771,9 @@ | |||
771 | </properties> | 771 | </properties> |
772 | <point/> | 772 | <point/> |
773 | </object> | 773 | </object> |
774 | <object id="5" name="spawn" type="warp" x="201.931" y="284.096"> | ||
775 | <point/> | ||
776 | </object> | ||
774 | </objectgroup> | 777 | </objectgroup> |
775 | <layer id="1" name="Layer 0" width="48" height="32"> | 778 | <layer id="1" name="Layer 0" width="48" height="32"> |
776 | <data encoding="csv"> | 779 | <data encoding="csv"> |
diff --git a/src/main.cpp b/src/main.cpp index b1fc373..62c81f3 100644 --- a/src/main.cpp +++ b/src/main.cpp | |||
@@ -26,7 +26,7 @@ void loop(Renderer& renderer) { | |||
26 | game.setMap(std::move(map)); | 26 | game.setMap(std::move(map)); |
27 | 27 | ||
28 | int lucasSprite = game.emplaceSprite("lucas"); | 28 | int lucasSprite = game.emplaceSprite("lucas"); |
29 | game.getSystem<TransformSystem>().initSprite(lucasSprite, {32, 32}); | 29 | game.getSystem<TransformSystem>().initSprite(lucasSprite, game.getMap().getWarpPoint("spawn")); |
30 | game.getSystem<TransformSystem>().setUpCollision(lucasSprite, {-8, -8}, {12, 8}); | 30 | game.getSystem<TransformSystem>().setUpCollision(lucasSprite, {-8, -8}, {12, 8}); |
31 | game.getSystem<AnimationSystem>().initSprite(lucasSprite, "../res/sprites/lucas_anim.txt", renderer); | 31 | game.getSystem<AnimationSystem>().initSprite(lucasSprite, "../res/sprites/lucas_anim.txt", renderer); |
32 | game.getSprite(lucasSprite).controllable = true; | 32 | game.getSprite(lucasSprite).controllable = true; |
diff --git a/src/map.cpp b/src/map.cpp index 1a2a250..2214d17 100644 --- a/src/map.cpp +++ b/src/map.cpp | |||
@@ -78,6 +78,12 @@ Map::Map(std::string_view filename, Renderer& renderer) { | |||
78 | } | 78 | } |
79 | 79 | ||
80 | prototypes_.push_back(std::move(p)); | 80 | prototypes_.push_back(std::move(p)); |
81 | } else if (object.getType() == "warp") { | ||
82 | vec2i point; | ||
83 | point.x() = object.getPosition().x; | ||
84 | point.y() = object.getPosition().y; | ||
85 | |||
86 | warpPoints_[object.getName()] = std::move(point); | ||
81 | } | 87 | } |
82 | } | 88 | } |
83 | } | 89 | } |
diff --git a/src/map.h b/src/map.h index a896b00..7bfb15e 100644 --- a/src/map.h +++ b/src/map.h | |||
@@ -1,6 +1,7 @@ | |||
1 | #ifndef MAP_H_D95D6D47 | 1 | #ifndef MAP_H_D95D6D47 |
2 | #define MAP_H_D95D6D47 | 2 | #define MAP_H_D95D6D47 |
3 | 3 | ||
4 | #include <map> | ||
4 | #include <string> | 5 | #include <string> |
5 | #include <string_view> | 6 | #include <string_view> |
6 | #include <vector> | 7 | #include <vector> |
@@ -48,6 +49,8 @@ public: | |||
48 | 49 | ||
49 | const std::vector<Prototype>& getPrototypes() const { return prototypes_; } | 50 | const std::vector<Prototype>& getPrototypes() const { return prototypes_; } |
50 | 51 | ||
52 | const vec2i& getWarpPoint(const std::string& name) const { return warpPoints_.at(name); } | ||
53 | |||
51 | private: | 54 | private: |
52 | 55 | ||
53 | vec2i mapSize_; | 56 | vec2i mapSize_; |
@@ -56,6 +59,7 @@ private: | |||
56 | int tilesetTextureId_; | 59 | int tilesetTextureId_; |
57 | int tilesetColumns_; | 60 | int tilesetColumns_; |
58 | std::vector<Prototype> prototypes_; | 61 | std::vector<Prototype> prototypes_; |
62 | std::map<std::string, vec2i> warpPoints_; | ||
59 | }; | 63 | }; |
60 | 64 | ||
61 | #endif /* end of include guard: MAP_H_D95D6D47 */ | 65 | #endif /* end of include guard: MAP_H_D95D6D47 */ |