feat(#8): move listeners to load

This commit is contained in:
Juan Sebastián Montoya 2024-09-14 17:43:53 -05:00
parent c1fe3acc11
commit 4e2905cf96

View file

@ -38,17 +38,20 @@ class Game extends GameObject {
this.canvas = canvas; this.canvas = canvas;
this.ctx = this.canvas.getContext("2d"); this.ctx = this.canvas.getContext("2d");
this.lastTime = 0; this.lastTime = 0;
}
async load() {
await super.load();
clicableObjects.forEach((elementId) => { clicableObjects.forEach((elementId) => {
document.getElementById(elementId).addEventListener("click", () => { document.getElementById(elementId).addEventListener("click", () => {
this.onMouseClick(elementId); this.onMouseClick(elementId);
}); });
document.addEventListener("keydown", (event) => { });
this.onKeyPressed(event.key); document.addEventListener("keydown", (event) => {
}); this.onKeyPressed(event.key);
document.addEventListener("keyup", (event) => { });
this.onKeyReleased(event.key); document.addEventListener("keyup", (event) => {
}); this.onKeyReleased(event.key);
}); });
} }