html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Snake Game</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
</head>
<body>
<h1>Snake Game</h1>
<div id="score-board">Score: <span id="current-score">0</span></div>
<div id="soundPause-toggle">
<button id="toggle-sound">Sounds: ON</button>
<button id="pauseToggleBtn" onclick="paused=!paused; this.textContent=`Pause: ${paused?'ON':'OFF'}`;">Pause: OFF</button>
</div>
<button id="show-leaderboard">Show Leaderboard</button>
<div id="game-board"></div>
<div id="start-overlay" class="overlay">
<div id="start-message" class="message">
<p>Press an arrow key or click a direction button to start the game.</p>
</div>
</div>
<div id="apple-overlay" class="overlay">
<div id="apple-message" class="message">
<div class="arrow"></div>
<p>Collect the apples to grow your snake and increase your score!</p>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
padding: 0;
background: linear-gradient(135deg, #1e3c72, #2a5298);
font-family: "Arial", sans-serif;
color: white;
overflow: hidden;
}
h1 {
font-size: 2rem;
margin-bottom: 10px;
text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}
#score-board {
font-size: 1.2rem;
font-weight: bold;
color: #ffdc73;
text-shadow: 0 3px 5px rgba(0, 0, 0, 0.4);
margin-bottom: 15px;
}
Enter to Rename, Shift+Enter to Preview
js
js
1
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run