Skip to content

FaizalZahid/Labyrinth-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Labyrinth-Generator

A labyrinth (maze) generator. Open-source code from a section (Self-Help) in House of Hikmah website (Labyrinth Therapy).

Also includes labyrinth solver!

Example of usage:

<!--more code here...-->

<body>
    <div>
        <p id="please-wait">Generating labyrinth...</p>
        <canvas id="maze" width="600" height="600"></canvas>
    </div>

    <script src="src/array.js"></script>
    <script src="src/cell.js"></script>
    <script src="src/graph.js"></script>
    <script src="src/labyrinthGenerator.js"></script>
    <script src="src/labyrinthSolver.js"></script>
    <script src="src/maze.js"></script>
    <script src="src/mazeGenerator.js"></script>
    <script>
      var maze = new Maze(document, 'maze');
      var generator = new labyrinthGenerator(15, 15);

      var waitElem = document.getElementById('please-wait');

      setTimeout(function() {
        generator.build();
        maze.draw(generator.graph);

        if (waitElem) {
          waitElem.remove();
        }
      }, 1000);
    </script>

</body>

<!--more code here...-->

To change the color for the maze, head to maze.js and you will find this line:

//more code here...

self.ctx.strokeStyle = "rgb(255, 255, 255)";
self.ctx.fillStyle = "rgb(0, 0, 0)";

//more code here...

And for the solution drawing color, on this line:

//more code here...

drawSolution: function(path) {
  self.ctx.fillStyle = "rgba(255, 255, 255, 0.8)";

//more code here...

Releases

No releases published

Sponsor this project

Packages

 
 
 

Contributors