Note: For some reason i cannot close this post, but i have found the answer. The reason was that, if you have ever programmed the recursive backtracking, i was looping through the stack which of course sped up the draw but while saving it still saved the old unmodified version.
I created a maze generator using sfml and cpp. Once the program is run it creates a maze saves its specs in the format of txt file and then proceed to save a image. Everything works fine, but if i increase the size of the grid or decrease the size of cell dimensions some part of the maze is not saved in the image.
What i see on the screen [dont worry about the not responding part] = first image
vs what is saved = second image
If you want to see the source code you can find it on my github:https://github.com/irrevocablesake/website-code/blob/master/Maze%20Generator/ep3/main.cpp
And if you want a walkthrough of the working of the code, you can read it on my blog:https://irrevocablesake.github.io/series/challenges/Maze%20Generator/index.html
Note for Mode: My blog is not monetized as of the timing and i am just treating it as a fun archive for projects and challenges.
if(once)
{
cout<<"maze done!!";
ofstream output("maze.txt");
output<<rows<<" "<<cols<<" "<<cellDimensions<<endl;
for(int i=0;i<rows;i++)
{
for(int j=0;j<cols;j++)
{
for(int k=0;k<4;k++)
{
output<<grid[j].wall[k]<<" ";
}
output<<endl;
}
}
// std::chrono::milliseconds timespan(60000);
// std::this_thread::sleep_for(timespan);
sf::Vector2u windowSize = window.getSize();
sf::Texture texture;
texture.create(windowSize.x, windowSize.y);
texture.update(window);
sf::Image screenshot = texture.copyToImage();
screenshot.saveToFile("sc.png");
once=0;
}
I feel like the last few statements where i try to save the image are the problem.
Thanks You!