From 3437e928e978939aa4c85369ab597e08f00ab93b Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Sun, 27 Nov 2016 16:28:51 -0500 Subject: world draw fix; offset fix --- main.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 982d70b..298fc6b 100644 --- a/main.cpp +++ b/main.cpp @@ -199,7 +199,7 @@ int main(int argc, char *argv[]) if (!worldDontReallyRun) { // the main loop, in all of its gloriousness.. - std::thread([&] { + std::thread thMain ([&] { const bool &run = game::engine.shouldRun; while (run) { game::time::mainLoopHandler(); @@ -211,10 +211,10 @@ int main(int argc, char *argv[]) std::this_thread::sleep_for(1ms); } - }).detach(); + }); // the debug loop, gets debug screen values - std::thread([&] { + std::thread thDebug ([&] { const bool &run = game::engine.shouldRun; while (run) { fps = 1000 / game::time::getDeltaTime(); @@ -222,13 +222,17 @@ int main(int argc, char *argv[]) std::this_thread::sleep_for(1s); } - }).detach(); + }); const bool &run = game::engine.shouldRun; while (run) { game::engine.render(0); render(); } + + thMain.join(); + thDebug.join(); + //game::engine.getSystem()->thAmbient.join(); } // put away the brice for later @@ -254,7 +258,8 @@ void render() { const auto SCREEN_WIDTH = game::SCREEN_WIDTH; const auto SCREEN_HEIGHT = game::SCREEN_HEIGHT; - offset.x = game::engine.getSystem()->getPosition().x;// + player->width / 2; + auto ps = game::engine.getSystem(); + offset.x = ps->getPosition().x + ps->getWidth() / 2; const auto& worldWidth = game::engine.getSystem()->getWidth(); if (worldWidth < (int)SCREEN_WIDTH) -- cgit v1.2.3