From 8fc8db2d784dc86915cd59789eb594ad36809833 Mon Sep 17 00:00:00 2001 From: MitchellHansen Date: Sat, 22 Aug 2015 16:24:11 -0700 Subject: [PATCH] Tweaked just a wee bit --- aStar/App.cpp | 6 +++++- aStar/Pather.cpp | 10 +++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/aStar/App.cpp b/aStar/App.cpp index 7661621..bed0fd0 100644 --- a/aStar/App.cpp +++ b/aStar/App.cpp @@ -29,6 +29,11 @@ void App::Input() { while (window->pollEvent(event)) { if (event.type == sf::Event::Closed) window->close(); + if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) { + sf::Vector2i mouse_position = sf::Mouse::getPosition(*window); + explorer->setDestination(sf::Vector2i(mouse_position.x/ 5, mouse_position.y/ 5)); + } + if (event.type == sf::Event::KeyPressed) { if (event.key.code == sf::Keyboard::Q) { explorer->setDestination(sf::Vector2i(20, 20)); @@ -99,7 +104,6 @@ void App::Render() { } // Draw the explorer - for (int x2 = 1; x2 < 5; x2++) { for (int y2 = 1; y2 < 5; y2++) { diff --git a/aStar/Pather.cpp b/aStar/Pather.cpp index 07a15e2..4cc4ff0 100644 --- a/aStar/Pather.cpp +++ b/aStar/Pather.cpp @@ -146,11 +146,11 @@ std::deque Pather::loop() { while (!openList.empty() && !early_exit) { // Early exit jankyness, need to change this - //if (closedList.size() > 3000) { - // no_path = true; - // early_exit = true; - // break; - //} + if (closedList.size() > 1000) { + no_path = true; + early_exit = true; + break; + } if (active_node->xy.x == end_node->xy.x && active_node->xy.y == end_node->xy.y) { early_exit = true; break;