-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
87 lines (74 loc) · 1.96 KB
/
index.html
File metadata and controls
87 lines (74 loc) · 1.96 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
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
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>My Snake Game</title>
<script src="mix_snake.js"></script>
</head>
<body>
<div align="center">
<h3>Simple snake(V1.0)</h3>
<h5>---------------------------author:JX </h5>
<div style="width:550px;margin:0 auto;height:400px;">
<div id="gamePanel" tabindex="0" style="width:400px; float:left;clear:left">
<canvas id="myCanvas" width="400" height="400" style="border:1px solid #c3c3c3;" >
Your browser does not support the canvas element.
</canvas>
</div>
<div id="scorePanel" style="float:right;">
<strong>Highest Score</strong>
<p></p>
<div id="highestScore" style="color:red; font-weight:bold;">
0
</div>
<p></p>
<strong>Score</strong>
<p></p>
<div id="score" style="font-weight:bold;">
0
</div>
</div>
</div>
<p>
speed: <select id="speed">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
</select>
<button id="start" onclick="startGame(this)">start</button>
<button id="control" onclick="control(this)" disabled="true">pause</button>
</p>
</div>
<script language="JavaScript">
var gameMrg = new Ga1900("myCanvas");
function startGame(startBtn){
var step = document.getElementById("speed").value;
gameMrg.startGame(step);
document.getElementById("gamePanel").focus();
pause = true;
var btn = document.getElementById("control");
btn.innerHTML = "pause";
btn.disabled = false;
}
var pause = true;
function control(btn){
if (pause) {
gameMrg.pause();
btn.innerHTML = "continue";
}
else{
gameMrg.goon();
btn.innerHTML = "pause";
document.getElementById("gamePanel").focus();
}
pause = !pause;
}
</script>
</body>
</html>