minesweeper some progress

This commit is contained in:
Geir Okkenhaug Jerstad 2024-09-03 13:34:37 +02:00
parent 96cca8c57a
commit 5f623b19cb
4 changed files with 176 additions and 28 deletions

42
MVC/tallpuslespill.html Normal file
View file

@ -0,0 +1,42 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app"></div>
<script>
// modell
let board = "73541 286";
// view
updateView();
function updateView(){
createSquareHtml(1)
+ createSquareHtml(2)
}
function createSquareHtml(index1, index2){
return /*HTML*/ `
<div onclick="swap(${index})">${board.charAt(index)}</div>
`;
}
// controller
function swap(){
let blankIndex = board.indexOf(' ');
let selectedNumber = board.charAt(index);
board = board.replace(' ', selectedNumber);
updateView();
};
function areNeighbours(){
};
</script>
</body>
</html>