js+css实现中国象棋人机对战游戏代码
代码语言:html
所属分类:游戏
代码描述:js+css实现中国象棋人机对战游戏代码
代码标签: js css 中国 象棋 人机 对战 游戏 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>中国象棋 - 人机对战</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
min-height: 100vh;
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
display: flex;
justify-content: center;
align-items: center;
font-family: 'Microsoft YaHei', '楷体', serif;
padding: 20px;
}
.game-container {
display: flex;
gap: 30px;
align-items: flex-start;
flex-wrap: wrap;
justify-content: center;
}
.board-wrapper {
background: linear-gradient(145deg, #8b6914, #a67c00);
padding: 25px;
border-radius: 15px;
box-shadow:
0 20px 60px rgba(0,0,0,0.5),
inset 0 2px 10px rgba(255,255,255,0.2),
inset 0 -2px 10px rgba(0,0,0,0.3);
}
.board-container {
position: relative;
background: linear-gradient(180deg, #f4d374 0%, #e8c252 50%, #f4d374 100%);
border-radius: 8px;
box-shadow: inset 0 0 20px rgba(0,0,0,0.2);
}
#chessboard {
display: block;
}
.control-panel {
background: linear-gradient(145deg, #2d3748, #1a202c);
padding: 25px;
border-radius: 15px;
box-shadow: 0 10px 40px rgba(0,0,0,0.4);
min-width: 200px;
color: #fff;
}
.panel-title {
font-size: 24px;
text-align: center;
margin-bottom: 20px;
color: #ffd700;
text-shadow: 0 2px 10px rgba(255,215,0,0.5);
}
.status {
background: linear-gradient(145deg, #3d4852, #2d3748);
padding: 15px;
border-radius: 10px;
margin-bottom: 20px;
text-align: center;
}
.status-label {
font-size: 14px;
color: #a0aec0;
margin-bottom: 5px;
}
.status-value {
font-size: 20px;
font-weight: bold;
}
.status-value.red-turn {
color: #fc8181;
}
.status-value.black-turn {
color: #68d391;
}
.btn {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
border: none;
border-radius: 8px;
font-size: 16px;
font-weight: bold;
cursor: pointer;
transition: all 0.3s ease;
font-family: inherit;
}
.btn-primary {
background: linear-gradient(145deg, #e53e3e, #c53030);
color: white;
}
.btn-primary:hover {
background: linear-gradient(145deg, #fc8181, #e53e3e);
transform: translateY(-2px);
box-shadow: 0 5px 20px rgba(229, 62, 62, 0.4);
}
.btn-secondary {
background: linear-gradient(145deg, #4a5568, #2d3748);
color: white;
}
.btn-secondary:hover {
background: linear-gradient(145deg, #718096, #4a5568);
transform: translateY(-2px);
}
.difficulty {
margin: 20px 0;
}
.difficulty-label {
font-size: 14px;
color: #a0aec0;
margin-bottom: 10px;
display: block;
}
.difficulty-select {
width: 100%;
padding: 10px;
border-radius: 8px;
border: none;
background: #3d4852;
color: white;
font-size: 14px;
cursor: pointer;
}
.history {
margin-top: 20px;
max-height: 200px;
overflow-y: auto;
}
.history-title {
font-size: 14px;
color: #a0aec0;
.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0