AI 生成: A classic Snake game built with HTML, CSS, and JavaScript. Control the snake to eat food, grow longer, and avoid hitting walls or yourself.

This commit is contained in:
admin
2026-10-01 19:31:11 +08:00
commit f43f5795e9
4 changed files with 318 additions and 0 deletions
+68
View File
@@ -0,0 +1,68 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: #1a1a2e;
color: #eee;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.game-container {
text-align: center;
padding: 20px;
}
h1 {
margin-bottom: 15px;
color: #4ecca3;
letter-spacing: 2px;
}
.score-board {
display: flex;
justify-content: space-between;
margin-bottom: 10px;
font-size: 16px;
color: #4ecca3;
}
canvas {
background: #16213e;
border: 3px solid #4ecca3;
border-radius: 8px;
display: block;
margin: 0 auto;
}
.controls {
margin-top: 15px;
}
button {
background: #4ecca3;
border: none;
color: #1a1a2e;
padding: 10px 25px;
font-size: 16px;
font-weight: bold;
border-radius: 5px;
cursor: pointer;
transition: background 0.2s;
}
button:hover {
background: #45b893;
}
.hint {
margin-top: 10px;
font-size: 13px;
color: #888;
}