Reputation: 561
I generate a maze using a randomized version of Kruskal's. The program logic for generating the maze is not an issue for me.I am having trouble figuring out how I would actually go about physically displaying the maze drawing.
To my understanding, the initial maze would start as a H by W grid, where each cell has all of its "borders"/walls in place. My only experience with C++ drawing is simply printing chars in the terminal, to represent different figures. However, it doesn't seem suited for more complex drawings like a cell of a certain width and height surrounded by 4 much thinner black lines. I suppose I could surround each cell character with 8 wall characters, but that seems quite cumbersome and not very elegant (walls would look bulky/ not thin).
I have seen some awesome screenshots on SO that people have taken of their generated maze, where they were able to draw the thin walls surrounded the cells with ease. I have never used a graphing/drawing library in C++ and after a few hours of search I am still quite lost.
For those algorithmic fanatics out there, what are the simplest frameworks to draw simple grids/mazes in C++?
Upvotes: 0
Views: 858
Reputation: 628
Without a specific library for displaying images you won't be able to actually show your image. OpenCV has a fantastic range of tools for generating, editing and displaying images. There are a huge amount of tutorials from step by step installation for your system to doing anything you may wish to do with OpenCV.
A simple enough method regardless of the libraries you use might be to
What you will end up with is a 2-tone image with walls the background colour and the path the foreground colour.
Unfortunately I cannot be any more specific without code examples or you picking the libraries you would like to use. OpenCV is widelyu used and so widely supported, so I recommend that.
Upvotes: 2