diff options
author | ymherklotz <ymherklotz@gmail.com> | 2016-12-11 14:58:33 +0000 |
---|---|---|
committer | ymherklotz <ymherklotz@gmail.com> | 2016-12-11 14:58:33 +0000 |
commit | 6183b0b485db3822bc2202e6f147ec426375a5d5 (patch) | |
tree | 5e254f565919da00ac547329bfe1e23a48851c3f | |
parent | 08a1b97bae118c24a3ae3998e229b1031fd03405 (diff) | |
download | A-star-algorithm-6183b0b485db3822bc2202e6f147ec426375a5d5.tar.gz A-star-algorithm-6183b0b485db3822bc2202e6f147ec426375a5d5.zip |
better commit
-rwxr-xr-x | bin/main | bin | 417472 -> 418208 bytes | |||
-rw-r--r-- | src/main.cpp | 16 |
2 files changed, 11 insertions, 5 deletions
Binary files differ diff --git a/src/main.cpp b/src/main.cpp index feb3bc0..dbc00ea 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,8 +21,11 @@ int main(int argc, char *argv[]) { cout << "executing " << argv[0] << endl; cout << "arguments given: " << argc - 1 << endl; + srand(time(NULL)); + // create a render window of size 800x600 with a title. sf::RenderWindow window(sf::VideoMode(2500, 1250), "A* Algorithm"); + window.setFramerateLimit(2); // print out the window size. cout << "window size: " << window.getSize().x << ", " << window.getSize().y << endl; @@ -49,9 +52,6 @@ int main(int argc, char *argv[]) { // create the array of the right size using the constants. int tiles[cols * rows]; - for(int i = 0; i < cols * rows; ++i) - tiles[i] = 0; - // create a tile map that will be used to display the array. TileMap map; @@ -81,9 +81,15 @@ int main(int argc, char *argv[]) { tiles[(int)(mouse.x / tile_size) + cols * (int)(mouse.y / tile_size)] = 0; } + // for(int i = 0; i < cols * rows; ++i) + // if(tiles[i] != 1) + // tiles[i] = 0; + for(int i = 0; i < cols * rows; ++i) - if(tiles[i] != 1) - tiles[i] = 0; + tiles[i] = 0; + + for(int i = 0; i < 600; ++i) + tiles[rand() % (cols * rows)] = 1; tiles[start_y * cols + start_x] = 3; tiles[end_y * cols + end_x] = 2; |