-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
29 lines (25 loc) · 860 Bytes
/
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
<!doctype html>
<html>
<head>
<title>Snake</title>
<meta charset="utf-8">
<script src="./snake.js"></script>
<link rel="stylesheet" href="snake.css">
</head>
<body>
<canvas width="800" height="400"></canvas>
<script>
var canvasWrapperInstance = new Snake();
document.onkeypress = function processKeyPress (event) {
var keyCode = event.keyCode;
var charCode = event.charCode;
keyCode = canvasWrapperInstance.tryDirectionMap(keyCode);
if (keyCode >= 37 && keyCode <= 40) {
return canvasWrapperInstance.moveSnake(keyCode);
} else if (charCode && canvasWrapperInstance.speedOperations.indexOf(charCode) !== -1) {
return canvasWrapperInstance.changeIntervalSpeed(charCode);
}
};
</script>
</body>
</html>