-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
31 lines (24 loc) · 835 Bytes
/
index.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
import Game from './game.js'
window.onload = () => {
var go_button = document.getElementById("start-rendering-button");
var started = false;
go_button.addEventListener("click", function(e){
if( started ) {
return;
}
started = true;
// Install handlers and initialise the game
var canvas = document.getElementById("webgl-canvas");
if( !canvas ) {
console.log("Failed to get game canvas :(");
return;
}
var game = new Game(canvas);
// canvas.addEventListener( "keydown", onKeyDown, true);
// canvas.addEventListener( "keyup", onKeyUp, true);
window.addEventListener( "keydown", game.onKeyDown, true);
window.addEventListener( "keyup", game.onKeyUp, true);
window.addEventListener( "resize", game.onWindowSize, true);
game.onWindowSize();
});
}