diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-09 18:27:03 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-09 18:27:03 -0500 |
commit | 9510e4fbbe817ab62ce014ee50283edd62fa00d9 (patch) | |
tree | 7d3562c7f9a15ea276642712718a83b0a6634add /src/map.cpp | |
parent | c85f91cc5e0f9e94717fbc36ebef3b2637986121 (diff) | |
download | tanetane-9510e4fbbe817ab62ce014ee50283edd62fa00d9.tar.gz tanetane-9510e4fbbe817ab62ce014ee50283edd62fa00d9.tar.bz2 tanetane-9510e4fbbe817ab62ce014ee50283edd62fa00d9.zip |
Entity prototypes can be stored in the map file now
Diffstat (limited to 'src/map.cpp')
-rw-r--r-- | src/map.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/map.cpp b/src/map.cpp index 0c4f9d6..1a2a250 100644 --- a/src/map.cpp +++ b/src/map.cpp | |||
@@ -51,6 +51,35 @@ Map::Map(std::string_view filename, Renderer& renderer) { | |||
51 | } | 51 | } |
52 | 52 | ||
53 | layers_.push_back(std::move(tilesToStore)); | 53 | layers_.push_back(std::move(tilesToStore)); |
54 | } else if (layer->getType() == tmx::Layer::Type::Object) { | ||
55 | const auto& objectLayer = layer->getLayerAs<tmx::ObjectGroup>(); | ||
56 | |||
57 | for (const tmx::Object& object : objectLayer.getObjects()) { | ||
58 | if (object.getType() == "sprite") { | ||
59 | Prototype p; | ||
60 | p.name = object.getName(); | ||
61 | p.pos.x() = object.getPosition().x; | ||
62 | p.pos.y() = object.getPosition().y; | ||
63 | |||
64 | for (const tmx::Property& property : object.getProperties()) { | ||
65 | if (property.getName() == "collisionOffsetX") { | ||
66 | p.collisionOffset.x() = property.getIntValue(); | ||
67 | } else if (property.getName() == "collisionOffsetY") { | ||
68 | p.collisionOffset.y() = property.getIntValue(); | ||
69 | } else if (property.getName() == "collisionWidth") { | ||
70 | p.collisionSize.w() = property.getIntValue(); | ||
71 | } else if (property.getName() == "collisionHeight") { | ||
72 | p.collisionSize.h() = property.getIntValue(); | ||
73 | } else if (property.getName() == "animation") { | ||
74 | p.animationFilename = property.getStringValue(); | ||
75 | } else if (property.getName() == "interactionScript") { | ||
76 | p.interactionScript = property.getStringValue(); | ||
77 | } | ||
78 | } | ||
79 | |||
80 | prototypes_.push_back(std::move(p)); | ||
81 | } | ||
82 | } | ||
54 | } | 83 | } |
55 | } | 84 | } |
56 | } | 85 | } |