diff --git a/SildePuzzle/kohi9noor/Assets/1.jpg b/SildePuzzle/kohi9noor/Assets/1.jpg new file mode 100644 index 000000000..58393522b Binary files /dev/null and b/SildePuzzle/kohi9noor/Assets/1.jpg differ diff --git a/SildePuzzle/kohi9noor/Assets/10.jpg b/SildePuzzle/kohi9noor/Assets/10.jpg new file mode 100644 index 000000000..28ae51acb Binary files /dev/null and b/SildePuzzle/kohi9noor/Assets/10.jpg differ diff --git a/SildePuzzle/kohi9noor/Assets/2.jpg b/SildePuzzle/kohi9noor/Assets/2.jpg new file mode 100644 index 000000000..e984855d2 Binary files /dev/null and b/SildePuzzle/kohi9noor/Assets/2.jpg differ diff --git a/SildePuzzle/kohi9noor/Assets/3.jpg b/SildePuzzle/kohi9noor/Assets/3.jpg new file mode 100644 index 000000000..1bcb710f9 Binary files /dev/null and b/SildePuzzle/kohi9noor/Assets/3.jpg differ diff --git a/SildePuzzle/kohi9noor/Assets/4.jpg b/SildePuzzle/kohi9noor/Assets/4.jpg new file mode 100644 index 000000000..21aaddac9 Binary files /dev/null and b/SildePuzzle/kohi9noor/Assets/4.jpg differ diff --git a/SildePuzzle/kohi9noor/Assets/5.jpg b/SildePuzzle/kohi9noor/Assets/5.jpg new file mode 100644 index 000000000..e6dc88323 Binary files /dev/null and b/SildePuzzle/kohi9noor/Assets/5.jpg differ diff --git a/SildePuzzle/kohi9noor/Assets/6.jpg b/SildePuzzle/kohi9noor/Assets/6.jpg new file mode 100644 index 000000000..7ac870f83 Binary files /dev/null and b/SildePuzzle/kohi9noor/Assets/6.jpg differ diff --git a/SildePuzzle/kohi9noor/Assets/7.jpg b/SildePuzzle/kohi9noor/Assets/7.jpg new file mode 100644 index 000000000..b935e2cdf Binary files /dev/null and b/SildePuzzle/kohi9noor/Assets/7.jpg differ diff --git a/SildePuzzle/kohi9noor/Assets/8.jpg b/SildePuzzle/kohi9noor/Assets/8.jpg new file mode 100644 index 000000000..824656080 Binary files /dev/null and b/SildePuzzle/kohi9noor/Assets/8.jpg differ diff --git a/SildePuzzle/kohi9noor/Assets/9.jpg b/SildePuzzle/kohi9noor/Assets/9.jpg new file mode 100644 index 000000000..f1bb93b03 Binary files /dev/null and b/SildePuzzle/kohi9noor/Assets/9.jpg differ diff --git a/SildePuzzle/kohi9noor/Assets/logo.png b/SildePuzzle/kohi9noor/Assets/logo.png new file mode 100644 index 000000000..a650de46e Binary files /dev/null and b/SildePuzzle/kohi9noor/Assets/logo.png differ diff --git a/SildePuzzle/kohi9noor/index.html b/SildePuzzle/kohi9noor/index.html new file mode 100644 index 000000000..2057b13c2 --- /dev/null +++ b/SildePuzzle/kohi9noor/index.html @@ -0,0 +1,17 @@ + + +
+ + +
+
+
+ let tile = document.createElement("img");
+ tile.id = r.toString() + "-" + c.toString();
+ tile.src = "./Assets/" + imgOrder.shift() + ".jpg";
+
+ //DRAG FUNCTIONALITY
+ tile.addEventListener("dragstart", dragStart); //click an image to drag
+ tile.addEventListener("dragover", dragOver); //moving image around while clicked
+ tile.addEventListener("dragenter", dragEnter); //dragging image onto another one
+ tile.addEventListener("dragleave", dragLeave); //dragged image leaving anohter image
+ tile.addEventListener("drop", dragDrop); //drag an image over another image, drop the image
+ tile.addEventListener("dragend", dragEnd); //after drag drop, swap the two tiles
+
+ document.getElementById("board").append(tile);
+
+ }
+ }
+}
+
+function dragStart() {
+ currTile = this; //this refers to the img tile being dragged
+}
+
+function dragOver(e) {
+ e.preventDefault();
+}
+
+function dragEnter(e) {
+ e.preventDefault();
+}
+
+function dragLeave() {
+
+}
+
+function dragDrop() {
+ otherTile = this; //this refers to the img tile being dropped on
+}
+
+function dragEnd() {
+ if (!otherTile.src.includes("3.jpg")) {
+ return;
+ }
+
+ let currCoords = currTile.id.split("-"); //ex) "0-0" -> ["0", "0"]
+ let r = parseInt(currCoords[0]);
+ let c = parseInt(currCoords[1]);
+
+ let otherCoords = otherTile.id.split("-");
+ let r2 = parseInt(otherCoords[0]);
+ let c2 = parseInt(otherCoords[1]);
+
+ let moveLeft = r == r2 && c2 == c-1;
+ let moveRight = r == r2 && c2 == c+1;
+
+ let moveUp = c == c2 && r2 == r-1;
+ let moveDown = c == c2 && r2 == r+1;
+
+ let isAdjacent = moveLeft || moveRight || moveUp || moveDown;
+
+ if (isAdjacent) {
+ let currImg = currTile.src;
+ let otherImg = otherTile.src;
+
+ currTile.src = otherImg;
+ otherTile.src = currImg;
+
+ turns += 1;
+ document.getElementById("turns").innerText = turns;
+ }
+
+
+}
\ No newline at end of file
diff --git a/SildePuzzle/kohi9noor/style.css b/SildePuzzle/kohi9noor/style.css
new file mode 100644
index 000000000..709a4cf7d
--- /dev/null
+++ b/SildePuzzle/kohi9noor/style.css
@@ -0,0 +1,27 @@
+body{
+ font-family: Arial, Helvetica, sans-serif;
+ text-align: center;
+ color: #0c67ae;
+}
+
+#title{
+ height: 150px;
+ width: 400px;
+}
+
+#board{
+ width: 360px;
+ height: 360px;
+ background-color: lightblue;
+ border: 10px solid #0c67ae;
+
+ margin: 0 auto;
+ display: flex;
+ flex-wrap: wrap;
+}
+
+#board img{
+ width: 118px;
+ height: 118px;
+ border: 1px solid #0c67ae;
+}
\ No newline at end of file