From 3a72ae005b3116f67c903ca7687276cc5547348c Mon Sep 17 00:00:00 2001 From: Renan LE CARO Date: Tue, 25 Mar 2025 08:33:09 +0100 Subject: [PATCH] Ascetism : render coins with red border if there's a combo --- dist/index.html | 15 +++++++++++---- src/render.ts | 19 ++++++++++++++----- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/dist/index.html b/dist/index.html index e44a62b..5979b0b 100644 --- a/dist/index.html +++ b/dist/index.html @@ -3417,6 +3417,7 @@ const background = document.createElement("img"); const backgroundCanvas = document.createElement("canvas"); function render(gameState) { const level = (0, _gameUtils.currentLevelInfo)(gameState); + const hasCombo = gameState.combo > (0, _gameStateMutators.baseCombo)(gameState); const { width, height } = gameCanvas; if (!width || !height) return; if (gameState.currentLevel || gameState.levelTime) menuLabel.innerText = (0, _i18N.t)("play.current_lvl", { @@ -3514,7 +3515,7 @@ function render(gameState) { ctx.globalAlpha = 1; (0, _gameStateMutators.forEachLiveOne)(gameState.coins, (coin)=>{ ctx.globalCompositeOperation = coin.color === "gold" || level.color ? "source-over" : "screen"; - drawCoin(ctx, coin.color, coin.size, coin.x, coin.y, level.color || "black", coin.a); + drawCoin(ctx, coin.color, coin.size, coin.x, coin.y, hasCombo && gameState.perks.asceticism && 'red' || level.color || "black", coin.a); }); // Black shadow around balls if (!(0, _options.isOptionOn)("basic")) { @@ -3572,7 +3573,7 @@ function render(gameState) { // The puck ctx.globalAlpha = 1; ctx.globalCompositeOperation = "source-over"; - drawPuck(ctx, gameState.puckColor, gameState.puckWidth, gameState.puckHeight, 0, !!gameState.perks.concave_puck, gameState.perks.streak_shots && gameState.combo > (0, _gameStateMutators.baseCombo)(gameState) ? getDashOffset(gameState) : -1); + drawPuck(ctx, gameState.puckColor, gameState.puckWidth, gameState.puckHeight, 0, !!gameState.perks.concave_puck, gameState.perks.streak_shots && hasCombo ? getDashOffset(gameState) : -1); if (gameState.combo > 1) { ctx.globalCompositeOperation = "source-over"; const comboText = "x " + gameState.combo; @@ -3585,7 +3586,6 @@ function render(gameState) { } else drawText(ctx, comboTextWidth > gameState.puckWidth ? gameState.combo.toString() : comboText, "#000", comboTextWidth > gameState.puckWidth ? 12 : 20, gameState.puckPosition, gameState.gameZoneHeight - gameState.puckHeight / 2, false); } // Borders - const hasCombo = gameState.combo > (0, _gameStateMutators.baseCombo)(gameState); ctx.globalCompositeOperation = "source-over"; ctx.globalAlpha = gameState.perks.unbounded ? 0.1 : 1; if (gameState.offsetXRoundedDown) { @@ -3730,9 +3730,16 @@ function drawCoin(ctx, color, size, x, y, borderColor, rawAngle) { canctx.arc(size / 2, size / 2, size / 2, 0, 2 * Math.PI); canctx.fillStyle = color; canctx.fill(); - if (color === "gold") { + if (color === 'gold' || borderColor === 'red') { canctx.strokeStyle = borderColor; + if (borderColor == 'red') { + canctx.lineWidth = 2; + canctx.setLineDash(redBorderDash); + } canctx.stroke(); + } + if (color === "gold") { + // Fill in canctx.beginPath(); canctx.arc(size / 2, size / 2, size / 2 * 0.6, 0, 2 * Math.PI); canctx.fillStyle = "rgba(255,255,255,0.5)"; diff --git a/src/render.ts b/src/render.ts index 3db337c..635785c 100644 --- a/src/render.ts +++ b/src/render.ts @@ -30,6 +30,8 @@ export const backgroundCanvas = document.createElement("canvas"); export function render(gameState: GameState) { const level = currentLevelInfo(gameState); + + const hasCombo = gameState.combo > baseCombo(gameState); const {width, height} = gameCanvas; if (!width || !height) return; @@ -168,9 +170,10 @@ export function render(gameState: GameState) { coin.size, coin.x, coin.y, - level.color || "black", + (hasCombo && gameState.perks.asceticism && 'red') || level.color || "black", coin.a, ); + }); // Black shadow around balls @@ -274,7 +277,7 @@ export function render(gameState: GameState) { gameState.puckHeight, 0, !!gameState.perks.concave_puck, - gameState.perks.streak_shots && gameState.combo > baseCombo(gameState) ? getDashOffset(gameState) : -1 + gameState.perks.streak_shots && hasCombo ? getDashOffset(gameState) : -1 ); if (gameState.combo > 1) { @@ -317,7 +320,6 @@ export function render(gameState: GameState) { } } // Borders - const hasCombo = gameState.combo > baseCombo(gameState); ctx.globalCompositeOperation = "source-over"; ctx.globalAlpha = gameState.perks.unbounded ? 0.1 : 1; @@ -637,10 +639,17 @@ export function drawCoin( canctx.fillStyle = color; canctx.fill(); - if (color === "gold") { - canctx.strokeStyle = borderColor; + if(color==='gold' || borderColor==='red'){ + canctx.strokeStyle = borderColor; + if(borderColor=='red'){ + canctx.lineWidth=2 + canctx.setLineDash(redBorderDash) + } canctx.stroke(); + } + if (color === "gold") { + // Fill in canctx.beginPath(); canctx.arc(size / 2, size / 2, (size / 2) * 0.6, 0, 2 * Math.PI); canctx.fillStyle = "rgba(255,255,255,0.5)";