diff options
Diffstat (limited to 'src/world.cpp')
-rw-r--r-- | src/world.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/world.cpp b/src/world.cpp index 5f696b5..508e2ac 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -18,6 +18,7 @@ #include <render.hpp> #include <engine.hpp> #include <components.hpp> +#include <player.hpp> // local library headers #include <tinyxml2.h> @@ -236,6 +237,8 @@ void WorldSystem::load(const std::string& file) } } + world.toLeft = world.toRight = ""; + // iterate through tags while (wxml) { std::string tagName = wxml->Name(); @@ -312,8 +315,12 @@ void WorldSystem::load(const std::string& file) if (loc != nullptr) { auto locVec = str2coord(loc); float locDat[2] = {locVec.x, locVec.y}; - entity.assign<Position>(locVec.x, locVec.y); + entity.assign<Position>(locDat[0], locDat[1]); } + + unsigned int health; + if (wxml->QueryUnsignedAttribute("health", &health) != XML_NO_ERROR) + entity.assign<Health>(health, health); } // hill creation @@ -989,3 +996,27 @@ void WorldSystem::detect(entityx::TimeDelta dt) } }); } + +void WorldSystem::goWorldRight(Position& p) +{ + if (!(world.toRight.empty()) && (p.x > world.startX * -1 - HLINES(10))) { + ui::toggleBlack(); + ui::waitForCover(); + auto file = world.toRight; + load(file); + p.x = world.startX + HLINES(15); + ui::toggleBlack(); + } +} + +void WorldSystem::goWorldLeft(Position& p) +{ + if (!(world.toLeft.empty()) && (p.x < world.startX + HLINES(10))) { + ui::toggleBlack(); + ui::waitForCover(); + auto file = world.toLeft; + load(file); + p.x = world.startX * -1 - HLINES(15); + ui::toggleBlack(); + } +} |