From 72b0ebea8bbeaf895343284b990e1643ba540f6e Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Fri, 29 Dec 2023 00:03:45 +0000 Subject: Clear canvas, preserve state --- js/game.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'js') diff --git a/js/game.js b/js/game.js index f39a6d1..6ed44bd 100644 --- a/js/game.js +++ b/js/game.js @@ -163,6 +163,9 @@ class Game { let ctx = this.canvas.getContext("2d"); + ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); + ctx.save(); + if (this.loadingError == true) { ctx.fillStyle = "rgb(255, 128, 128)"; ctx.font = "caption"; @@ -180,6 +183,8 @@ class Game { Math.floor(ctx.canvas.resSize * (ctx.canvas.width - Math.floor(ctx.canvas.width * 0.2)) / ctx.canvas.dataSize) ), h); + ctx.restore(); + // we don't do this on update because we want // the progress bar to finish drawing if (this.resSize == this.dataSize) { -- cgit v1.2.3