Skip to content

Commit 949b19d

Browse files
authored
Update mEvent.js
1 parent aec861d commit 949b19d

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

PathFinder/JavaScript/mEvent.js

+17-13
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,16 @@ $(document).on("mousedown", function(event) {
6767
var xf = Math.floor(mouseX / w);
6868
var yf = Math.floor(mouseY / h);
6969

70-
grid[xc][yc].wall = false;
71-
grid[xc][yc].visited = false;
72-
grid[xc][yc].showyou(color(255));
70+
if(grid[xf][yf].wall != true) {
71+
grid[xc][yc].wall = false;
72+
grid[xc][yc].visited = false;
73+
grid[xc][yc].showyou(color(255));
74+
75+
strt = grid[xf][yf];
76+
strt.showyou(color(0, 255, 0));
77+
grid[xf][yf].showyou(color(0, 255, 0));
78+
}
7379

74-
strt = grid[xf][yf];
75-
strt.showyou(color(0, 255, 0));
76-
grid[xf][yf].showyou(color(0, 255, 0));
7780
$(this).unbind("mouseup");
7881
});
7982
} else if (grid[xc][yc] == end) {
@@ -82,13 +85,14 @@ $(document).on("mousedown", function(event) {
8285
var xf = Math.floor(mouseX / w);
8386
var yf = Math.floor(mouseY / h);
8487

85-
grid[xc][yc].wall = false;
86-
grid[xc][yc].visited = false;
87-
grid[xc][yc].showyou(color(255));
88-
89-
end = grid[xf][yf];
90-
end.showyou(color(255, 0, 0));
88+
if(grid[xf][yf].wall != true) {
89+
grid[xc][yc].wall = false;
90+
grid[xc][yc].visited = false;
91+
grid[xc][yc].showyou(color(255));
9192

93+
end = grid[xf][yf];
94+
end.showyou(color(255, 0, 0));
95+
}
9296
$(this).unbind("mouseup");
9397
});
9498
}
@@ -115,4 +119,4 @@ $(document).on("mousedown", function(event) {
115119
});
116120
}
117121
}
118-
});
122+
});

0 commit comments

Comments
 (0)