git repos / saland

commit 63c01ac9

Poul Sander · 2018-10-16 14:07
63c01ac9f60dd60886ba53d6e328232ac446708b patch · browse files
parent 01ef90a379918094f282a6f87a7e84aaf121e7e4

Load the tilesets based on source

Changed files

M src/saland/model/World.cpp before
diff --git a/src/saland/model/World.cpp b/src/saland/model/World.cpp index 0d3640d..fd09826 100644 --- a/src/saland/model/World.cpp +++ b/src/saland/model/World.cpp
@@ -144,11 +144,15 @@ void World::init_physics(std::shared_ptr<b2World>& world) {
void World::init(std::shared_ptr<b2World>& world, const std::string& mapFileName) {
this->physicsWorld = world;
- std::string tsx_file = sago::GetFileContent("maps/terrain.tsx");
std::string tmx_file = sago::GetFileContent(mapFileName);
- ts = sago::tiled::string2tileset(tsx_file);
tm = sago::tiled::string2tilemap(tmx_file);
- tm.tileset.at(0).alternativeSource = &ts;
+ for (size_t i = 0; i < tm.tileset.size(); ++i) {
+ if (tm.tileset[i].source.length()) {
+ std::string tsx_file = sago::GetFileContent("maps/"+tm.tileset[i].source);
+ ts = sago::tiled::string2tileset(tsx_file);
+ tm.tileset[i].alternativeSource = &ts;
+ }
+ }
init_physics(world);
}