-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
53 lines (48 loc) · 1.26 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
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Asterois</title>
<script src="elm.js" type="text/javascript" charset="utf-8"></script>
<style type="text/css" media="screen">
body {
background-color: #222;
}
div#game {
border: 2px solid #666;
width: 400px;
height: 400px;
margin: 100px auto;
}
</style>
</head>
<body>
<audio id="snd-laser" src="snd/Laser.mp3" preload="auto"></audio>
<audio id="snd-hit" src="snd/Hit.mp3" preload="auto"></audio>
<audio id="snd-crash" src="snd/Crash.mp3" preload="auto"></audio>
<audio id="snd-spawn" src="snd/Spawn.mp3" preload="auto"></audio>
<div id="game"></div>
<script>
// Init game
var div = document.getElementById('game');
var game = Elm.embed(Elm.Main, div);
function playSound(s) {
var a = document.getElementById('snd-' + s);
if (a === null ) {
console.log('unknown sound: ' + s);
} else {
a.currentTime = 0;
a.play();
}
}
function playSounds(l) {
console.log(l);
for(var i=0; i<l.length; i++) {
playSound( l[i] );
}
}
// Setup ports
game.ports.sfxPort.subscribe(playSounds);
</script>
</body>
</html>