@@ -67,13 +67,16 @@ $(document).on("mousedown", function(event) {
67
67
var xf = Math . floor ( mouseX / w ) ;
68
68
var yf = Math . floor ( mouseY / h ) ;
69
69
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
+ }
73
79
74
- strt = grid [ xf ] [ yf ] ;
75
- strt . showyou ( color ( 0 , 255 , 0 ) ) ;
76
- grid [ xf ] [ yf ] . showyou ( color ( 0 , 255 , 0 ) ) ;
77
80
$ ( this ) . unbind ( "mouseup" ) ;
78
81
} ) ;
79
82
} else if ( grid [ xc ] [ yc ] == end ) {
@@ -82,13 +85,14 @@ $(document).on("mousedown", function(event) {
82
85
var xf = Math . floor ( mouseX / w ) ;
83
86
var yf = Math . floor ( mouseY / h ) ;
84
87
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 ) ) ;
91
92
93
+ end = grid [ xf ] [ yf ] ;
94
+ end . showyou ( color ( 255 , 0 , 0 ) ) ;
95
+ }
92
96
$ ( this ) . unbind ( "mouseup" ) ;
93
97
} ) ;
94
98
}
@@ -115,4 +119,4 @@ $(document).on("mousedown", function(event) {
115
119
} ) ;
116
120
}
117
121
}
118
- } ) ;
122
+ } ) ;
0 commit comments