summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp2
-rw-r--r--src/map.cpp6
-rw-r--r--src/map.h4
3 files changed, 11 insertions, 1 deletions
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
51private: 54private:
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 */