Optimizar avisandole al navegador de cosas que no necesitamos

This commit is contained in:
Nulo 2021-06-30 22:59:09 +00:00
parent 475946568c
commit e75fe64b96
1 changed files with 7 additions and 2 deletions

View File

@ -39,7 +39,9 @@ function update(juego: Juego<any>, dt: number) {
function draw(juego: Juego<any>, 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<HTMLCanvasElement>("#juego")!
const ctx = canvas.getContext("2d")!
const ctx = canvas.getContext("2d", {
alpha: false,
desynchronized: true,
})!
window.addEventListener("resize", () => resizeCanvas(canvas), false)
resizeCanvas(canvas)