js+css实现围棋人机对战游戏代码
代码语言:html
所属分类:游戏
代码描述: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, user-scalable=yes">
<title>弈境 · 围棋人机对战 | 新手到高手</title>
<style>
:root {
--bg: #f5efe0;
--wood-light: #dbbc7c;
--wood-dark: #8b6b42;
--panel-bg: rgba(245, 235, 210, 0.65);
--text: #3b2c1a;
--gold: #b68b5c;
--shadow: 0 20px 40px rgba(60, 30, 10, 0.3);
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: #e8dcc8;
font-family: 'Noto Serif SC', '楷体', 'KaiTi', '华文楷体', 'STKaiti', '宋体', 'SimSun', 'Georgia', serif;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
padding: 16px;
background-image:
radial-gradient(circle at 25% 35%, rgba(210, 180, 140, 0.3) 0%, transparent 50%),
radial-gradient(circle at 75% 65%, rgba(190, 150, 100, 0.25) 0%, transparent 50%),
linear-gradient(160deg, #e7d7b8 0%, #cfb991 40%, #c4a87a 100%);
position: relative;
background-attachment: fixed;
}
body::before {
content: "";
position: fixed;
inset: 0;
background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="300" height="300" viewBox="0 0 300 300"><filter id="paper"><feTurbulence type="fractalNoise" baseFrequency="0.03" numOctaves="5" result="noise"/><feDiffuseLighting in="noise" lightingColor="%23fdf7ed" surfaceScale="2.5"><feDistantLight azimuth="55" elevation="50"/></feDiffuseLighting></filter><rect width="100%" height="100%" filter="url(%23paper)" opacity="0.45"/></svg>');
opacity: 0.5;
pointer-events: none;
z-index: 0;
}
.main-container {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: flex-start;
gap: 24px;
position: relative;
z-index: 2;
max-width: 1050px;
width: 100%;
}
/* 棋盘面板 */
.board-panel {
background: var(--panel-bg);
backdrop-filter: blur(6px);
border-radius: 36px;
padding: 20px 22px;
box-shadow: var(--shadow), inset 0 2px 10px rgba(255, 255, 240, 0.8);
border: 1px solid #d4b68a;
display: flex;
flex-direction: column;
align-items: center;
gap: 14px;
}
canvas#gobanCanvas {
display: block;
border-radius: 24px;
box-shadow: 0 18px 35px rgba(50, 25, 5, 0.5), 0 0 0 2px #b39264, 0 0 0 5px #5e3e1c;
cursor: pointer;
transition: filter 0.15s;
max-width: 100%;
height: auto;
}
.info-row {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
gap: 12px;
width: 100%;
}
.turn-badge {
display: flex;
align-items: center;
gap: 8px;
background: #e7d7b8;
padding: 7px 18px;
border-radius: 30px;
font-weight: 600;
color: #4b3621;
box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.08);
font-size: 0.95rem;
}
.stone-icon {
width: 22px;
height: 22px;
border-radius: 50%;
display: inline-block;
}
.stone-icon.black {
background: radial-gradient(circle at 35% 35%, #555, #1a1a1a);
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
}
.stone-icon.white {
background: radial-gradient(circle at 35% 35%, #fefefe, #c0c0c0);
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
}
.thinking-indicator {
display: flex;
align-items: center;
gap: 10px;
background: #f3e5ca;
padding: 7px 18px;
border-radius: 30px;
font-style: italic;
color: #5e3a1c;
font-weight: 500;
animation: pulse-fade 1.2s ease-in-out infinite;
}
@keyframes pulse-fade {
0%,
100% {
opacity: 1;
}
50% {
opacity: 0.5;
}
}
.spinner-ring {
width: 24px;
height: 24px;
border: 3px solid #c8aa7a;
border-top: 3px solid #3e2b1a;
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
.diffic.........完整代码请登录后点击上方下载按钮下载查看















网友评论0