Optimizar avisandole al navegador de cosas que no necesitamos
This commit is contained in:
parent
475946568c
commit
e75fe64b96
1 changed files with 7 additions and 2 deletions
|
@ -39,7 +39,9 @@ function update(juego: Juego<any>, dt: number) {
|
||||||
function draw(juego: Juego<any>, timestamp: number) {
|
function draw(juego: Juego<any>, timestamp: number) {
|
||||||
const { width, height } = juego.canvas
|
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) {
|
switch (juego.state.current) {
|
||||||
case "welcome":
|
case "welcome":
|
||||||
welcome.draw(juego, timestamp)
|
welcome.draw(juego, timestamp)
|
||||||
|
@ -63,7 +65,10 @@ function resizeCanvas(canvas: HTMLCanvasElement) {
|
||||||
|
|
||||||
async function initJuego() {
|
async function initJuego() {
|
||||||
const canvas = document.querySelector<HTMLCanvasElement>("#juego")!
|
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)
|
window.addEventListener("resize", () => resizeCanvas(canvas), false)
|
||||||
resizeCanvas(canvas)
|
resizeCanvas(canvas)
|
||||||
|
|
Loading…
Reference in a new issue