summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp4
-rw-r--r--src/map.cpp15
2 files changed, 18 insertions, 1 deletions
diff --git a/src/game.cpp b/src/game.cpp index 8b6ef8f..fcd5f44 100644 --- a/src/game.cpp +++ b/src/game.cpp
@@ -59,7 +59,9 @@ void Game::loadMap(std::string filename, std::string warpPoint, Direction dir) {
59 int spriteId = emplaceSprite(p.name); 59 int spriteId = emplaceSprite(p.name);
60 getSystem<TransformSystem>().initSprite(spriteId, p.pos); 60 getSystem<TransformSystem>().initSprite(spriteId, p.pos);
61 getSystem<TransformSystem>().setUpCollision(spriteId, p.collisionOffset, p.collisionSize, true); 61 getSystem<TransformSystem>().setUpCollision(spriteId, p.collisionOffset, p.collisionSize, true);
62 getSystem<AnimationSystem>().initSprite(spriteId, p.animationFilename); 62 if (!p.animationFilename.empty()) {
63 getSystem<AnimationSystem>().initSprite(spriteId, p.animationFilename);
64 }
63 getSprite(spriteId).interactionScript = p.interactionScript; 65 getSprite(spriteId).interactionScript = p.interactionScript;
64 } 66 }
65 67
diff --git a/src/map.cpp b/src/map.cpp index 8d4aa2d..da382fd 100644 --- a/src/map.cpp +++ b/src/map.cpp
@@ -99,6 +99,21 @@ Map::Map(std::string_view name) : name_(name) {
99 } 99 }
100 100
101 triggers_.push_back(std::move(t)); 101 triggers_.push_back(std::move(t));
102 } else if (object.getType() == "tileSprite") {
103 Prototype p;
104 p.name = object.getName();
105 p.pos.x() = std::floor(object.getPosition().x / 16) * 16;
106 p.pos.y() = std::floor(object.getPosition().y / 16) * 16;
107 p.collisionOffset = { 0, 0 };
108 p.collisionSize = { 16, 16 };
109
110 for (const tmx::Property& property : object.getProperties()) {
111 if (property.getName() == "interactionScript") {
112 p.interactionScript = property.getStringValue();
113 }
114 }
115
116 prototypes_.push_back(std::move(p));
102 } 117 }
103 } 118 }
104 } 119 }