-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
187 lines (153 loc) · 4.88 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<!DOCTYPE html>
<html>
<head>
<title>Racing Game</title>
<meta charset="UTF-8">
<meta name="description" content="a webgl game">
<meta name="keywords" content="webgl game canvas javascript">
<meta name="author" content="nemo">
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="app/css/game.css" />
<script src="libs/Three.js"></script>
<script src="libs/jquery-1.6.4.js"></script>
<script src="libs/jquery.mousewheel.js"></script>
<script src="libs/RequestAnimationFrame.js"></script>
<script src="libs/digitaldisplay.js"></script>
<script src="libs/speedometer.js"></script>
<script src="libs/themes/default.js"></script>
<script src="libs/themes/racing-black.js"></script>
<script src="sim/sim.js"></script>
<script src="sim/animation.js"></script>
<script src="sim/webGLDetector.js"></script>
<script src="app/jsonModel.js"></script>
<script src="app/car.js"></script>
<script src="app/player.js"></script>
<script src="app/exhaust.js"></script>
<script src="app/environment.js"></script>
<script src="app/game.js"></script>
<script src="app/xcanvas.js"></script>
<script src="app/tbe.js"></script>
<script>
var game_volume = 1;
function loadSounds()
{
var sounds = {
driving : document.getElementById ('driving'),
rev_short : document.getElementById ('rev_short'),
rev_long : document.getElementById ('rev_long'),
bounce : document.getElementById ('bounce'),
crash : document.getElementById ('crash'),
};
return sounds;
}
function adjustVolume(sounds, volume)
{
for (sound in sounds)
{
sounds[sound].volume = volume;
}
}
var app = null;
$(document).ready(
function() {
var container = document.getElementById("container");
try {
Sim.WebGLDetector.detectWebGL();
var timer = document.getElementById ('elapsedTime');
var odometer = document.getElementById ('odometer');
var kmph = document.getElementById ('kmph');
var rpm = document.getElementById ('rpm');
var sounds = loadSounds();
adjustVolume(sounds, game_volume);
// using speedometer components
speedometer = new Speedometer ('speedometer', {theme: 'racing-black', max:250,
threshold:150});
speedometer.draw ();
speedometer.addEventListener ('speedometer:animateend', function () {
controls.start ();
});
// The tachometer
tachometer = new Speedometer ('tachometer', {theme: 'racing-black', max:5000,
threshold:3500});
tachometer.draw();
tachometer.addEventListener ('speedometer:animateend', function () {
tachcontrols.start ();
});
app = new RacingGame();
app.init({ container: container,
hud: {
speedometer:speedometer,
tachometer:tachometer,
timer:timer,
odometer:odometer,
},
sounds : sounds,
});
timer.style.display = 'block';
odometer.style.display = 'block';
kmph.style.display = 'block';
rpm.style.display = 'block';
app.focus();
app.run();
}
catch(e)
{
container.innerHTML = e.toString();
}
}
);
function onRestartClicked()
{
app.restart();
}
</script>
</head>
<body>
<center><h1>Road Race!</h1></center>
<div id="container" style="width:100%; height:100%; position:absolute; outline:none; background-color:#3fafdd;"></div>
<div id="kmph">
km/h
<div id="speedometer"></div>
</div>
<div id="rpm">
rpm
<div id="tachometer"></div>
</div>
<div id="odometer">
0.00
</div>
<div id="elapsedTime">
0.00
</div>
<div id="overlay" class="overlay" >
<div id="header" class="header">Race Complete</div>
<div id="contents" class="contents">
Elapsed Time: 42.43s<br></br>
Best Time: 39.31s
</div>
<div id="restartButton" class="restartButton">
<button onclick="onRestartClicked(this);">再来一次</button></div>
</div>
<!-- imports autio fils here -->
<audio id="driving">
<source src="sounds/50910__rutgermuller__in-car-driving.wav" type="audio/wav" />
Your browser does not support WAV files in the audio element.
</audio>
<audio id="rev_short">
<source src="sounds/rev-short.wav" type="audio/wav" />
Your browser does not support WAV files in the audio element.
</audio>
<audio id="rev_long">
<source src="sounds/rev-trimmed.wav" type="audio/wav" />
Your browser does not support WAV files in the audio element.
</audio>
<audio id="bounce">
<source src="sounds/bounce.wav" type="audio/wav" />
Your browser does not support WAV files in the audio element.
</audio>
<audio id="crash">
<source src="sounds/crash-trimmed.wav" type="audio/wav" />
Your browser does not support WAV files in the audio element.
</audio>
</body>
</html>