Added a maze solver object to handle the search algorithms that will be used to solve the maze. Updated the sketch code to use said object.
This commit is contained in:
@@ -5,15 +5,15 @@ class Cell {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.walls = [true, true, true, true];
|
||||
this.selected = false;
|
||||
this.visited = false;
|
||||
this.cellWidth = cellWidth;
|
||||
this.searched = false;
|
||||
this.finalPath = false;
|
||||
this.parent = undefined;
|
||||
this.end = false;
|
||||
this.start = false;
|
||||
}
|
||||
this.color = [255, 255, 255, 0];
|
||||
}
|
||||
|
||||
get defaultColor(){
|
||||
return [255, 255, 255, 0];
|
||||
}
|
||||
|
||||
get top(){
|
||||
return this.walls[0];
|
||||
@@ -58,32 +58,8 @@ class Cell {
|
||||
if (this.bottom) line(x + this.cellWidth, y + this.cellWidth, x, y + this.cellWidth);
|
||||
if (this.left) line(x, y, x, y + this.cellWidth);
|
||||
|
||||
if (this.visited) {
|
||||
fill(255, 0, 0);
|
||||
noStroke();
|
||||
rect(x, y, this.cellWidth, this.cellWidth);
|
||||
}
|
||||
|
||||
if(this.searched){
|
||||
fill(210, 180, 140);
|
||||
noStroke();
|
||||
rect(x, y, this.cellWidth, this.cellWidth);
|
||||
}
|
||||
|
||||
if (this.selected) {
|
||||
fill(50, 125, 0);
|
||||
noStroke();
|
||||
rect(x, y, this.cellWidth, this.cellWidth);
|
||||
}
|
||||
|
||||
if(this.finalPath){
|
||||
fill(173, 216, 230);
|
||||
noStroke();
|
||||
rect(x, y, this.cellWidth, this.cellWidth);
|
||||
}
|
||||
|
||||
if(this.start){
|
||||
text("Start", x, y + cellWidth / 2);
|
||||
}
|
||||
fill(this.color);
|
||||
noStroke();
|
||||
rect(x, y, this.cellWidth, this.cellWidth);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user