-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
61 lines (56 loc) · 1.66 KB
/
Copy pathmain.js
File metadata and controls
61 lines (56 loc) · 1.66 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
var gamejs = require('gamejs');
// custom
var Director = require('./game').Director;
var scenes = require('./scenes');
var touchSupport = require('./touch');
gamejs.preload([
'images/corners.png',
'images/core.png',
'images/1x.png',
'images/2x.png',
'images/3x.png',
'images/about-screen.png',
'images/boom.png',
'images/wall.png',
'images/win-screen.png',
'images/lose-screen.png',
'images/next-screen.png',
'sounds/impactcrunch01.ogg',
'sounds/impactcrunch02.ogg',
'sounds/impactcrunch03.ogg',
'sounds/impactcrunch05.ogg',
'sounds/34201__themfish__glass_house1.ogg',
'sounds/34202__themfish__glass_house2.ogg',
'sounds/game_over.ogg',
'sounds/30306__ERH__tension.ogg'
]);
function $(id) {
return document.getElementById(id);
}
gamejs.ready(function() {
touchSupport.init();
// IEBUG CHROMEBUG
// very ugly hack until they fixes some of their
// audio bugs we disable audio completely
if (navigator.userAgent.indexOf('Chrome') > -1 || navigator.userAgent.indexOf('MSIE') > -1 ||
navigator.userAgent.indexOf('Safari') > -1) {
gamejs.mixer.Sound = function() {
return {
play: function() {}
};
};
}
// html GUI
$('saveButton').addEventListener('click', function() {
$('saveArea').value = director.getScene().getLevelDump();
}, false);
$('loadButton').addEventListener('click', function() {
var dump = $('loadArea').value;
director.getScene().setLevelDump(dump);
}, false);
// startup gamejs game
var director = new Director();
var firstScene = new scenes.StartScreen(director);
director.start(firstScene);
return;
});