feat: 添加贪吃蛇和记忆配对纸牌游戏
- 贪吃蛇游戏: Canvas渲染、方向控制、碰撞检测、计分系统 - 记忆配对纸牌: 3D翻转动画、配对消除、计时器、胜利判定
This commit is contained in:
+175
@@ -0,0 +1,175 @@
|
||||
<!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%);
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 20px;
|
||||
color: #fff;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2.5rem;
|
||||
margin-bottom: 20px;
|
||||
text-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
|
||||
background: linear-gradient(90deg, #00ffff, #ff00ff);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-clip: text;
|
||||
}
|
||||
#stats {
|
||||
display: flex;
|
||||
gap: 40px;
|
||||
margin-bottom: 20px;
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
.stat {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
padding: 10px 25px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
.stat-value {
|
||||
color: #00ffcc;
|
||||
font-weight: bold;
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
#game-board {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 100px);
|
||||
gap: 15px;
|
||||
perspective: 1000px;
|
||||
}
|
||||
.card {
|
||||
width: 100px;
|
||||
height: 140px;
|
||||
position: relative;
|
||||
transform-style: preserve-3d;
|
||||
transition: transform 0.6s ease, opacity 0.5s ease;
|
||||
cursor: pointer;
|
||||
}
|
||||
.card.flipped {
|
||||
transform: rotateY(180deg);
|
||||
}
|
||||
.card.matched {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transform: rotateY(180deg) scale(0.8);
|
||||
}
|
||||
.card-face {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
backface-visibility: hidden;
|
||||
border-radius: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 3rem;
|
||||
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
.card-back {
|
||||
background: linear-gradient(145deg, #e94560, #c23a51);
|
||||
border: 3px solid #ff6b6b;
|
||||
}
|
||||
.card-back::before {
|
||||
content: '?';
|
||||
font-size: 3rem;
|
||||
color: rgba(255, 255, 255, 0.3);
|
||||
font-weight: bold;
|
||||
}
|
||||
.card-front {
|
||||
background: linear-gradient(145deg, #f8f9fa, #e9ecef);
|
||||
transform: rotateY(180deg);
|
||||
border: 3px solid #ddd;
|
||||
}
|
||||
.card:hover:not(.flipped):not(.matched) {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
#restart-btn {
|
||||
margin-top: 25px;
|
||||
padding: 15px 40px;
|
||||
font-size: 1.2rem;
|
||||
background: linear-gradient(90deg, #00b894, #00cec9);
|
||||
border: none;
|
||||
border-radius: 30px;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 2px;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 4px 15px rgba(0, 206, 201, 0.4);
|
||||
}
|
||||
#restart-btn:hover {
|
||||
transform: translateY(-3px);
|
||||
box-shadow: 0 6px 20px rgba(0, 206, 201, 0.6);
|
||||
}
|
||||
#win-modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 1000;
|
||||
}
|
||||
.modal-content {
|
||||
background: linear-gradient(145deg, #2d3436, #1e272e);
|
||||
padding: 50px;
|
||||
border-radius: 20px;
|
||||
text-align: center;
|
||||
box-shadow: 0 0 50px rgba(0, 255, 255, 0.3);
|
||||
border: 2px solid rgba(0, 255, 255, 0.3);
|
||||
}
|
||||
.modal-content h2 {
|
||||
font-size: 3rem;
|
||||
margin-bottom: 20px;
|
||||
background: linear-gradient(90deg, #f1c40f, #e74c3c);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-clip: text;
|
||||
}
|
||||
.modal-content p {
|
||||
font-size: 1.3rem;
|
||||
margin-bottom: 30px;
|
||||
color: #bdc3c7;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>记忆配对纸牌</h1>
|
||||
<div id="stats">
|
||||
<div class="stat">步数: <span id="moves" class="stat-value">0</span></div>
|
||||
<div class="stat">时间: <span id="timer" class="stat-value">0:00</span></div>
|
||||
<div class="stat">配对: <span id="pairs" class="stat-value">0/8</span></div>
|
||||
</div>
|
||||
<div id="game-board"></div>
|
||||
<button id="restart-btn">重新开始</button>
|
||||
|
||||
<div id="win-modal">
|
||||
<div class="modal-content">
|
||||
<h2>🎉 恭喜胜利!</h2>
|
||||
<p>你用了 <span id="final-moves">0</span> 步,耗时 <span id="final-time">0:00</span></p>
|
||||
<button id="play-again-btn" style="padding: 15px 40px; font-size: 1.2rem; background: linear-gradient(90deg, #00b894, #00cec9); border: none; border-radius: 30px; color: white; cursor: pointer; font-weight: bold;">再来一局</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="memory.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user