diff --git a/index.js b/index.js index 97d31b4..8c59081 100644 --- a/index.js +++ b/index.js @@ -38,17 +38,20 @@ class Game extends GameObject { this.canvas = canvas; this.ctx = this.canvas.getContext("2d"); this.lastTime = 0; + } + async load() { + await super.load(); clicableObjects.forEach((elementId) => { document.getElementById(elementId).addEventListener("click", () => { this.onMouseClick(elementId); }); - document.addEventListener("keydown", (event) => { - this.onKeyPressed(event.key); - }); - document.addEventListener("keyup", (event) => { - this.onKeyReleased(event.key); - }); + }); + document.addEventListener("keydown", (event) => { + this.onKeyPressed(event.key); + }); + document.addEventListener("keyup", (event) => { + this.onKeyReleased(event.key); }); }