-
Notifications
You must be signed in to change notification settings - Fork 0
/
snake.html
110 lines (99 loc) · 2.89 KB
/
snake.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!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="assets/styles.css">
<style>
/* styles.css */
body {
font-family: 'Arial', sans-serif;
margin: 0;
padding: 0;
background-color: #1a1a1a;
color: #ffffff;
overflow-x: hidden; /* Prevent horizontal scrollbar */
}
.section {
text-align: center;
}
.section-content {
max-width: 1500px;
margin: 0 auto;
}
.section-title {
font-size: 2rem;
color: #61dafb;
margin-bottom: 2rem;
}
.game-container {
background-color: #0f0f0f;
padding: 1rem;
border-radius: 10px;
position: relative;
}
#snake-game {
display: block;
margin: 0 auto;
border: 2px solid #61dafb;
background-color: #1a1a1a;
border-radius: 10px;
}
.score {
font-size: 1.5rem;
color: #ffffff;
margin-bottom: 10px;
}
.game-button {
padding: 10px 20px;
font-size: 1rem;
border: none;
border-radius: 5px;
background-color: #61dafb;
color: #1a1a1a;
cursor: pointer;
margin-top: 10px;
transition: background-color 0.3s ease;
}
.game-button:hover {
background-color: #ffffff;
color: #1a1a1a;
}
.game-over {
display: none;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
background: rgba(0, 0, 0, 0.8);
padding: 20px;
border-radius: 10px;
}
.game-over p {
margin: 0 0 10px 0;
font-size: 1.5rem;
color: #ff0000;
}
</style>
</head>
<body>
<script src="assets/redirect.js"></script>
<section id="game" class="section">
<div class="section-content">
<h2 class="section-title">Snake</h2>
<div id="game-container" class="game-container">
<div id="score" class="score">Score: 0</div>
<canvas id="snake-game" width="1400" height="600"></canvas>
<button id="start-button" class="game-button">Start Game</button>
<div id="game-over" class="game-over">
<p>You died!</p>
<button id="respawn-button" class="game-button">Respawn</button>
</div>
</div>
</div>
</section>
<script src="assets/snake.js"></script>
</body>
</html>