JavaScript跳棋游戏求助:黄色棋子无法执行捕获操作
跳棋游戏黄方捕获操作无法完成问题
我之前编写红棋移动检查函数时犯过算术错误,导致程序定位到错误单元格,这让我意识到函数编写完成后做检查的重要性。
目前我的跳棋游戏整体运行正常,规则为黄方先行,之后红方行动。现在遇到的问题是:当黄方发起捕获时,红棋会按预期被跳过,但黄棋却无法完成捕获操作。
因代码篇幅限制,JavaScript代码较长,以下仅展示HTML与CSS部分:
<!DOCTYPE html> <html> <head> <link rel="stylesheet" href="styles.css"/> <script src="main.js"></script> </head> <body> <div id="playerA"></div> <center><table id="checkertable"></table></center> <div id="playerA"></div> </body> </html>
body{ background:green; } /*style the table*/ .table{ margin:auto; width:560px; height:560px; } .square{ width:70px; height:70px; } .white{ background-color:mintcream; } .brown{ background-color:chocolate; } /*styles for the pieces*/ .gold-piece { box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5); background-color: gold; width: 80%; height: 80%; border-radius: 50%; margin: 10%; } .red-piece { box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5); background-color:orangered; width: 80%; height: 80%; border-radius: 50%; margin: 10%; } /*style for styling a selected piece*/ .selected-piece{ border:2px solid white; }
内容的提问来源于stack exchange,提问作者Anthony Kinyua
相关产品推荐
相关产品推荐

