From e75fe64b961e6ec1018d06dd21603c32f8559ee8 Mon Sep 17 00:00:00 2001 From: Nulo Date: Wed, 30 Jun 2021 22:59:09 +0000 Subject: [PATCH] Optimizar avisandole al navegador de cosas que no necesitamos --- src/main.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main.ts b/src/main.ts index b6d0c64..aff9b2e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -39,7 +39,9 @@ function update(juego: Juego, dt: number) { function draw(juego: Juego, timestamp: number) { const { width, height } = juego.canvas - juego.ctx.clearRect(0, 0, width, height) + juego.ctx.fillStyle = "white" + juego.ctx.fillRect(0, 0, width, height) + juego.ctx.fillStyle = "black" switch (juego.state.current) { case "welcome": welcome.draw(juego, timestamp) @@ -63,7 +65,10 @@ function resizeCanvas(canvas: HTMLCanvasElement) { async function initJuego() { const canvas = document.querySelector("#juego")! - const ctx = canvas.getContext("2d")! + const ctx = canvas.getContext("2d", { + alpha: false, + desynchronized: true, + })! window.addEventListener("resize", () => resizeCanvas(canvas), false) resizeCanvas(canvas)