Skip to content

Commit

Permalink
Start/end can no longer be placed on walls
Browse files Browse the repository at this point in the history
  • Loading branch information
tobinatore committed Sep 8, 2020
1 parent 7d35e4e commit fc90684
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pathfinding.html
Original file line number Diff line number Diff line change
Expand Up @@ -720,15 +720,21 @@ <h4>Useful Links</h4>
if (d == "start") {
var newX = Math.round((gridX - 1) / 25);
var newY = Math.round((gridY - 1) / 25);
if (newX != endPos.x || newY != endPos.y) {
if (
(newX != endPos.x || newY != endPos.y) &&
gridData[newY][newX].type != "wall"
) {
startPos.x = newX;
startPos.y = newY;
d3.select(this).attr("x", gridX).attr("y", gridY);
}
} else {
var newX = Math.round((gridX - 1) / 25);
var newY = Math.round((gridY - 1) / 25);
if (newX != startPos.x || newY != startPos.y) {
if (
(newX != startPos.x || newY != startPos.y) &&
gridData[newY][newX].type != "wall"
) {
endPos.x = Math.round((gridX - 1) / 25);
endPos.y = Math.round((gridY - 1) / 25);
d3.select(this).attr("x", gridX).attr("y", gridY);
Expand All @@ -738,8 +744,6 @@ <h4>Useful Links</h4>

var gridData = gridData();

console.log(gridData);
console.log(grid);
var drag = d3
.drag()
.subject(function () {
Expand Down Expand Up @@ -914,6 +918,7 @@ <h4>Useful Links</h4>
}, delay)
);
}

async function colorBlock(block, color, delayDraw, delay, mode) {
return new Promise((resolve) => {
if (mode == "fill") {
Expand Down

0 comments on commit fc90684

Please sign in to comment.