Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ICell
- {
- public:
- int x;
- int y;
- ICell* previous;
- bool visited;
- bool up;
- bool left;
- };
- class IResult
- {
- public:
- std::vector<ICell> path;
- sf::Image* img;
- int time;
- int steps;
- };
- IResult BFSsolve(sf::Image& img, int xstart, int ystart, int xend, int yend)
- {
- int width = img.GetWidth();
- int height = img.GetHeight();
- sf::Clock clock;
- std::queue<ICell> cellq;
- ICell cells[width/2][height/2];
- std::cout << width << "\n";
- for(int i = 0; i < width / 2; i++)
- {
- for(int k = 0; k < height / 2; k++)
- {
- //std::cout << k << "\n";
- cells[i][k].x = i;
- cells[i][k].y = k;
- cells[i][k].visited = false;
- }
- }
- std::cout << width << "\n";
- for(int g = 0; g <= width; g++)
- {
- for(int h = 0; h <= height; h++)
- {
- int rx = g;
- int ry = h;
- if((h == 0) || (img.GetPixel(g, h - 1) == sf::Color::Black))
- {
- cells[g/2][h/2].up = true;
- }
- if((g == 0) || (img.GetPixel(g - 1, h) == sf::Color::Black))
- {
- cells[g/2][h/2].left = true;
- }
- }
- }
- cells[xstart][ystart].visited = true;
- std::cout << xstart << " " << ystart << "\n";
- std::cout << cells[xstart][ystart].x << " " << cells[xstart][ystart].y << "\n";
- cellq.push(cells[xstart][ystart]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement