-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
47 lines (47 loc) · 1.4 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>snake</title>
<style>
body {
/* https://systemfontstack.com/ */
font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir,
segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto,
arial, sans-serif;
max-width: 400px;
margin: auto;
text-align: center;
}
button {
width: 4rem;
height: 4rem;
font-size: 100%;
}
</style>
</head>
<body>
<main>
<h1>snake</h1>
<canvas
style="image-rendering: pixelated; width: 100%"
id="canvas"
></canvas>
<!-- onpointerdown is a better experience for mobile than onclick -->
<button onpointerdown="changeDir('ArrowLeft')">⬅️</button>
<button onpointerdown="changeDir('ArrowDown')">⬇️</button>
<button onpointerdown="changeDir('ArrowUp')">⬆️</button>
<button onpointerdown="changeDir('ArrowRight')">➡️</button>
<div>
<p>arrow keys work too!</p>
<a href="./snake.js">view the code</a>
<br />
<a href="https://www.onsclom.net/posts/javascript-is-misunderstood/"
>why does this exist?</a
>
</div>
</main>
<script src="snake.js"></script>
</body>
</html>