-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
60 lines (52 loc) · 1.5 KB
/
main.js
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
import Game from './libs/Game.js';
(function() {
var html = document.documentElement;
var canvas = document.getElementById("myCanvas");
var config, game;
canvas.width = html.clientWidth > 750 ? 750 : html.clientWidth;
canvas.height = html.clientHeight;
config = {
backImage: document.getElementById("back"),
shipImage: document.getElementById("ship"),
rocks: [
{
node: document.getElementById('rock-A'),
width: 72,
height:72,
num: 18,
counter: 5
},
{
node: document.getElementById('rock-B'),
width: 72,
height:72,
num: 18,
counter: 5
}
],
rockExplosionImage: {
node: document.getElementById('rock-explosion'),
width: 64,
height: 64,
num: 15,
counter: 4
},
shipExplosionImage: {
node: document.getElementById('ship-explosion'),
width: 96,
height: 96,
num: 17,
counter: 5
},
bulletImage: document.getElementById('bullet')
};
// todo load game control
console.log(config.shipImage.complete);
game = new Game(canvas, config);
document.addEventListener("keypress", function(e) {
if (e.keyCode === 13) {
game.init();
game.start();
}
});
})();