我想做一个简单的国际象棋游戏(我正在学习JavaScript)。除了移动棋子,我已经做了一切。 有人可以解释一下我该怎么做吗?我只想将它们从1平方英寸移动到没有任何游戏原理的地方。
<script>
document.addEventListener("DOMContentLoaded", function() {
const checkers = document.querySelectorAll('.board');
const squares = document.querySelectorAll('#checker1 td');
for (const checker of checkers) {
checker.addEventListener("click", function(){
const tableVisibility = this.firstElementChild.style.visibility;
if (tableVisibility != 'visible') {
this.firstElementChild.style.visibility = (tableVisibility == '')?'hidden':'';
}
}, false);
}
for (const square of squares) {
square.addEventListener("click", function() {
const styleComputed = getComputedStyle(this);
const calaPlansza = this.parentElement.parentElement.parentElement;
if {(popedPiece == null) && (styleComputed.cursor == 'pointer')) {
this.style.setProperty('visibility', )
}
if {(popedPiece != null) && (styleComputed.cursor != 'pointer')) {
this.style.setProperty('opacity', "")
this.classList.add(popedPiece.className);
popedPiece = null;
calaPlansza.dataset.moves = (calaPlansza.dataset.moves == '');
}
}, false);
}
}, false);
/**/
var Clicked = false;
</script>