krisb1220 / minesweeper Goto Github PK
View Code? Open in Web Editor NEWThis is a fully complete Minesweeper game. Minesweeper solver coming after!
License: Creative Commons Attribution 4.0 International
This is a fully complete Minesweeper game. Minesweeper solver coming after!
License: Creative Commons Attribution 4.0 International
Padding cells are no longer needed after the implementation of the following code. Logic for tile 1, tile x, last cell, and last cell - x is needed before padding cells can be deleted.
//right
if(field.fieldObject[value.integerLocation + 1].hasBomb && value.integerLocation % field.x != 2 ) {
bombsInCell++;
}
//left
if(field.fieldObject[value.integerLocation - 1].hasBomb && value.integerLocation % field.x != 3) {
bombsInCell++;
}
//top
if(field.fieldObject[value.integerLocation - field.x].hasBomb) {
bombsInCell++;
}
//top right
if(field.fieldObject[(value.integerLocation - field.x)+1].hasBomb && value.integerLocation % field.x != 2 ) {
bombsInCell++;
}
//top left
if(field.fieldObject[(value.integerLocation - field.x)-1].hasBomb && value.integerLocation % field.x != 3) {
bombsInCell++;
}
//bottom
if(field.fieldObject[value.integerLocation + field.x].hasBomb) {
bombsInCell++;
}
//bottom right
if(field.fieldObject[(value.integerLocation + field.x)+1].hasBomb && value.integerLocation % field.x != 2 ) {
bombsInCell++;
}
//bottom left
if(field.fieldObject[(value.integerLocation + field.x)-1].hasBomb && value.integerLocation % field.x != 3 ) {
bombsInCell++;
}
The current procedure appends the numbers to each element BEFORE the buttons are clicked. For both cheating & general flow reasons, it should be AFTER the click.
The error is happening because of the following code in game.js
:
function detectClicks() {
let tiles = document.querySelectorAll(".tile")
forEach(tiles, function(tile){
tile.addEventListener("click", function(event){
clicked = field.fieldObject[event.target.id]
if(event.shiftKey) {
placeFlag(clicked);
}
else if(!event.shiftKey){
clicked.hasBomb ? lose() : mineTile(clicked);
}
});
});
and the following code in game-helpers.js
from line 128 - 131
if(!tile.isMined) {
document.getElementById(tile.integerLocation).innerHTML = "<p class='number'>" + tile.bombsInCell + "</p>";
document.getElementById(tile.integerLocation).classList.add("tile-mined");
}
This can be fixed by changing the tile numbering from an ID to a class, then appending the classname to the paragraph holding the number.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.