-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
124 lines (105 loc) · 2.37 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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!DOCTYPE html>
<html>
<head>
<title>HTML5 Canvas PONG game</title>
<script type="text/javascript" src="lib/Game.js"></script>
<script type="text/javascript" src="lib/Background.js"></script>
<script type="text/javascript" src="lib/Paddle.js"></script>
<script type="text/javascript" src="lib/Player.js"></script>
<script type="text/javascript" src="lib/Opponent.js"></script>
<script type="text/javascript" src="lib/Ball.js"></script>
<style type="text/css">
body
{
margin: 0px;
padding: 0px;
text-align: center;
}
canvas
{
margin: 0px auto;
}
fieldset
{
border: none;
}
label
{
display: block;
}
input
{
margin-bottom: 10px;
}
.controls
{
float: left;
text-align: left;
}
.form
{
float: right;
text-align: right;
}
.clear
{
clear: both;
}
.container
{
width: 740px;
margin: 0px auto;
}
</style>
</head>
<body>
<h1>HTML5 Canvas Game - Pong</h1>
<div class="container">
<canvas id="pong" width="740" height="640">
This browser can not run this game (canvas support missing).
</canvas>
<div class="clear"></div>
<div class="controls">
<h3>Controls</h3>
<h4>Player 1</h4>
<ul>
<li>Pause - P</li>
<li>Left - Left Arrow</li>
<li>Right - Right Arrow</li>
</ul>
<h4>Player 2</h4>
<ul>
<li>Pause - P</li>
<li>Left - A</li>
<li>Right - D</li>
</ul>
</div>
<div class="form">
<form action="#" method="get" id="settings">
<fieldset>
<label for="number_of_players">No. of Players</label>
<input type="number" value="1" min="1" max="2" id="number_of_players" name="number_of_players">
</fieldset>
<fieldset>
<label for="difficulty">Difficulty</label>
<input type="number" value="5" min="1" id="difficulty" name="difficulty">
</fieldset>
<fieldset>
<input type="button" name="start" value="Start" onclick="Javascript: startGame();">
</fieldset>
</form>
</div>
<div class="clear"></div>
</div>
<script type="text/javascript">
var game = new Game("pong");
function startGame()
{
var form = document.getElementById("settings");
game.number_of_players = form.number_of_players.value;
game.difficulty = form.difficulty.value;
game.start();
}
</script>
</body>
</html>