-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathauto.html
More file actions
51 lines (49 loc) 路 1.29 KB
/
Copy pathauto.html
File metadata and controls
51 lines (49 loc) 路 1.29 KB
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
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Snake ASTAR Auto</title>
</head>
<style>
body {
text-align: center;
font-family: calibri;
}
</style>
<body>
<h2>arsan.dev Snake AI with A* Algorithm</h2>
<canvas></canvas>
<h1>Score: <span id="score">0</span> | Time: <span id="time">0</span>s</h1>
<p><b>Mode: <font color="red">Automatic (BOT)</font></b></p>
<button type="button" onclick="location.reload()">Refresh</button>
<button type="button" id="play">Play</button>
<button type="button" id="pause" hidden>Pause</button>
<script src="snake.js" charset="utf-8"></script>
<script type="text/javascript">
var snake = new Game({
size: 400,
blockSize: 15,
fps: 25,
utils: {
showGrid: true,
distance: true,
distanceCount: true,
distancePerpendicular: true
},
aStar: true
});
var playBtn = document.querySelector("#play");
var pauseBtn = document.querySelector("#pause");
playBtn.addEventListener("click", function(){
this.hidden = true;
pauseBtn.hidden = false;
snake.play();
});
pauseBtn.addEventListener("click", function(){
this.hidden = true;
playBtn.hidden = false;
snake.pause();
});
</script>
</body>
</html>