aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorymherklotz <ymherklotz@gmail.com>2016-12-11 16:10:05 +0000
committerymherklotz <ymherklotz@gmail.com>2016-12-11 16:10:05 +0000
commit0c1f72762e9c0fbc03bb07db2219cff3b4427f3e (patch)
tree9f8124aa9642e269cb42490dd8c0b14195afe4d9
parentaa0bafd57f8be07a8214d592c1bbc10d8f5448a5 (diff)
downloadA-star-algorithm-0c1f72762e9c0fbc03bb07db2219cff3b4427f3e.tar.gz
A-star-algorithm-0c1f72762e9c0fbc03bb07db2219cff3b4427f3e.zip
final push today
-rwxr-xr-xbin/mainbin416144 -> 416200 bytes
-rw-r--r--src/main.cpp21
2 files changed, 15 insertions, 6 deletions
diff --git a/bin/main b/bin/main
index 4fb270d..9d9d0a3 100755
--- a/bin/main
+++ b/bin/main
Binary files differ
diff --git a/src/main.cpp b/src/main.cpp
index 4098b9a..14f46e8 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -24,7 +24,7 @@ int main(int argc, char *argv[]) {
// create a render window of size 800x600 with a title.
sf::RenderWindow window(sf::VideoMode(2500, 1250), "A* Algorithm");
- // window.setFramerateLimit(2);
+ // window.setFramerateLimit(1);
// print out the window size.
cout << "window size: " << window.getSize().x << ", " << window.getSize().y << endl;
@@ -39,11 +39,11 @@ int main(int argc, char *argv[]) {
const int rows = 50;
const int cols = 100;
- const int start_x = 9;
- const int start_y = 13;
+ int start_x = rand() % cols;
+ int start_y = rand() % rows;
- const int end_x = 76;
- const int end_y = 38;
+ int end_x = rand() % cols;
+ int end_y = rand() % rows;
// print out that information.
cout << "tile size: " << tile_size << "px, rows: " << rows << ", cols: " << cols << endl;
@@ -90,14 +90,23 @@ int main(int argc, char *argv[]) {
// for(int i = 0; i < cols * rows; ++i)
// tiles[i] = 0;
//
- // for(int i = 0; i < 600; ++i)
+ // for(int i = 0; i < 1500; ++i)
// tiles[rand() % (cols * rows)] = 1;
+ // start_x = rand() % cols;
+ // start_y = rand() % rows;
+ //
+ // end_x = rand() % cols;
+ // end_y = rand() % rows;
+
tiles[start_y * cols + start_x] = 3;
tiles[end_y * cols + end_x] = 2;
path_finder.start_algorithm(tiles, cols, rows);
+ tiles[start_y * cols + start_x] = 3;
+ tiles[end_y * cols + end_x] = 2;
+
// update tile map with the correct array.
map.load("res/GridTileTexture5.png", sf::Vector2f(200, 200), sf::Vector2f(tile_size, tile_size), tiles, cols, rows);