From 7a4bc1d9e6b73471cb2e20d2ab0611a507979f30 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Thu, 20 Oct 2016 09:23:52 -0400 Subject: ortho follows cat, bobshouse can be opened --- main.cpp | 9 ++++++--- src/world.cpp | 46 +--------------------------------------------- xml/!town.xml | 2 +- xml/bobshouse.xml | 5 +++-- 4 files changed, 11 insertions(+), 51 deletions(-) diff --git a/main.cpp b/main.cpp index 4b579b2..7a4f0ca 100644 --- a/main.cpp +++ b/main.cpp @@ -266,11 +266,14 @@ void render() { const auto SCREEN_WIDTH = game::SCREEN_WIDTH; const auto SCREEN_HEIGHT = game::SCREEN_HEIGHT; -// offset.x = player->loc.x + player->width / 2; + //offset.x = game::entities.Iterator.begin().component().x;// + player->width / 2; - auto worldWidth = game::engine.getSystem()->getWidth(); + game::entities.each([](entityx::Entity entity, Position &position) { + (void)entity; + offset.x = position.x; + }); - // ortho x snapping + auto worldWidth = game::engine.getSystem()->getWidth(); if (worldWidth < (int)SCREEN_WIDTH) offset.x = 0; else if (offset.x - SCREEN_WIDTH / 2 < worldWidth * -0.5f) diff --git a/src/world.cpp b/src/world.cpp index 15fde50..6405382 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -330,51 +330,7 @@ loadWorldFromXMLNoSave(std::string path) { newEntity = nullptr; name = wxml->Name(); - // world linkage - if (name == "link") { - - // links world to the left - if ((ptr = wxml->Attribute("left"))) { - tmp->setToLeft(ptr); - - // load the left world if it isn't - if (!loadedLeft) { - loadedRight = true; - currentWorldToLeft = loadWorldFromXMLNoSave(ptr); - loadedRight = false; - } else { - currentWorldToLeft = nullptr; - } - } - - // links world to the right - else if ((ptr = wxml->Attribute("right"))) { - tmp->setToRight(ptr); - - // load the right world if it isn't - if (!loadedRight) { - loadedLeft = true; - currentWorldToRight = loadWorldFromXMLNoSave(ptr); - loadedLeft = false; - } else { - currentWorldToRight = nullptr; - } - } - - // tells what world is outside, if in a structure - else if (Indoor && (ptr = wxml->Attribute("outside"))) { -// if (!loadedLeft && !loadedRight) -// inside.push_back(ptr); - } - - // error, invalid link tag - else { - UserError("XML Error: Invalid tag in " + _currentXML + "!"); - } - - } - - // set spawn x for player + // set spawn x for player else if (name == "spawnx" && !(loadedLeft | loadedRight)) { player->loc.x = std::stoi(wxml->GetText()); } diff --git a/xml/!town.xml b/xml/!town.xml index bfaa6a9..0530762 100644 --- a/xml/!town.xml +++ b/xml/!town.xml @@ -7,7 +7,7 @@ - + diff --git a/xml/bobshouse.xml b/xml/bobshouse.xml index a1d4e7c..41ca907 100644 --- a/xml/bobshouse.xml +++ b/xml/bobshouse.xml @@ -1,8 +1,9 @@