From c41317fb70b346e8a4373962bc800cc8a3929209 Mon Sep 17 00:00:00 2001 From: nau7ilus Date: Thu, 22 Aug 2024 23:04:40 +0200 Subject: [PATCH] [drawer] rename images to preloadedImages --- drawer/lib/drawer.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drawer/lib/drawer.js b/drawer/lib/drawer.js index 9fa6d6b..c709955 100644 --- a/drawer/lib/drawer.js +++ b/drawer/lib/drawer.js @@ -69,7 +69,7 @@ const RANK_BAR_Y = 720; const RANK_BAR_BG_COLOR = '#2A313A'; const RANK_BAR_RADII = 5; -let images = null; +let preloadedImages = null; async function preload() { registerFont(path.join(__dirname, './assets/junegull.ttf'), { family: 'Junegull' }); @@ -77,16 +77,16 @@ async function preload() { const loadPromises = Object.values(foundImages).map((p) => loadImage(p)); const loaded = await Promise.all(loadPromises); const imagesEntries = Object.keys(foundImages).map((k, i) => [k, loaded[i]]); - images = Object.fromEntries(imagesEntries); + preloadedImages = Object.fromEntries(imagesEntries); } async function initCanvas(type, locale) { // If the pictures have not loaded yet, do this - if (!images) await preload(); + if (!preloadedImages) await preload(); const canvas = createCanvas(WIDTH, HEIGHT); const ctx = canvas.getContext('2d'); // Set background preset - const background = images[`base/${locale}/${type}Bg`]; + const background = preloadedImages[`base/${locale}/${type}Bg`]; ctx.drawImage(background, 0, 0); return { canvas, ctx }; } @@ -131,7 +131,7 @@ function setAttemptsLeft(ctx, attemptsLeft) { } function addHangman(ctx, type) { - const hangman = images[`sprites/${type}`]; + const hangman = preloadedImages[`sprites/${type}`]; ctx.drawImage(hangman, ...HANGMAN_COORDS); }