forked from jakesgordon/javascript-pong
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
97 lines (80 loc) · 2.86 KB
/
Copy pathindex.html
File metadata and controls
97 lines (80 loc) · 2.86 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
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<html>
<head>
<title>Pong!</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link href="pong.css" media="screen, print" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="sidebar">
<h2>经典街机游戏Pong的javascript版本!</h2>
<ul class='parts'>
<li><a href='#' class='selected'>重新开始游戏</a></li>
<li><a href='/part1'><i>游戏Runner</i> - Part 1</a></li>
<li><a href='/part2'><i>弹跳球</i> - Part 2</a></li>
<li><a href='/part3'><i>游戏循环</i> - Part 3</a></li>
<li><a href='/part4'><i>碰撞检测</i> - Part 4</a></li>
<li><a href='/part5'><i>人工智能的实现</i> - Part 5</a></li>
</ul>
<div class='description'>
<p>
这是Pong的javascript版本。
</p>
<p>
按<b>1</b>可玩单人游戏。<br>
按<b>2</b>可玩双人游戏。<br>
按<b>0</b>可观看电脑(AI)玩游戏。
</p>
<p>
玩家1使用<b>Q</b>和<b>A</b>键移动。<br>
玩家2使用<b>P</b>和<b>L</b>键移动。
</p>
<p>
<b>Esc</b>可用于放弃游戏。
</p>
</div>
<div class='settings'>
<label for='sound'>声音:</label>
<input type='checkbox' id='sound'>
</div>
<div class='settings'>
<label for='stats'>统计信息: </label>
<input type='checkbox' id='stats' checked>
</div>
<div class='settings'>
<label for='footprints'>痕迹: </label>
<input type='checkbox' id='footprints' checked>
</div>
<div class='settings'>
<label for='predictions'>预测:</label>
<input type='checkbox' id='predictions'>
</div>
</div>
<canvas id="game">
<div id="unsupported">
很抱歉,无法运行,因为您的浏览器不支持&canvas&元素
</div>
</canvas>
<script src="game.js" type="text/javascript"></script>
<script src="pong.js" type="text/javascript"></script>
<script type="text/javascript">
Game.ready(function() {
var size = document.getElementById('size');
var sound = document.getElementById('sound');
var stats = document.getElementById('stats');
var footprints = document.getElementById('footprints');
var predictions = document.getElementById('predictions');
var pong = Game.start('game', Pong, {
sound: sound.checked,
stats: stats.checked,
footprints: footprints.checked,
predictions: predictions.checked
});
Game.addEvent(sound, 'change', function() { pong.enableSound(sound.checked); });
Game.addEvent(stats, 'change', function() { pong.showStats(stats.checked); });
Game.addEvent(footprints, 'change', function() { pong.showFootprints(footprints.checked); });
Game.addEvent(predictions, 'change', function() { pong.showPredictions(predictions.checked); });
});
</script>
</body>
</html>