Credit to Wikipedia for its handy article on maze generation - https://en.wikipedia.org/wiki/Maze_generation_algorithm A loading screen, loops nicely. Press the s key to edit Press the h key to hide editing variables How it works: The sprite starts at a random position on a grid and generates a list containing the coordinates of the 4 surrounding points. Then, it goes through this list and deletes every point that has already been visited. When the list has been checked through to ensure every point contained within it is really an open point, it will select a random item on the list, move to it contained in the list, and generate a new list of adjacent coordinates. It will continue doing this until there are no available adjacent points to access. At that point, the sprite will backtrack through the maze until it finds a point with a neighbor that has not yet been visited and start a new path there. When there are no remaining unvisited cells, the algorithm is complete. The sprite is visible as mostly transparent circle, you can watch it do its thing if the pen color is dark enough. This particular maze will generate completely before it actually 'loads'. This is so the pen color can change as you move the mouse - the sprite will re-render it to one more iteration every time. It remembers the maze by adding every decision it makes when originally generating to a list, then when rendering simply follows the decisions outlined in the list instead of making random ones.