summary refs log tree commit diff stats
path: root/src/map.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp29
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}