Ascetism : render coins with red border if there's a combo

This commit is contained in:
Renan LE CARO 2025-03-25 08:33:09 +01:00
parent fe5c33f999
commit 3a72ae005b
2 changed files with 25 additions and 9 deletions

15
dist/index.html vendored
View file

@ -3417,6 +3417,7 @@ const background = document.createElement("img");
const backgroundCanvas = document.createElement("canvas"); const backgroundCanvas = document.createElement("canvas");
function render(gameState) { function render(gameState) {
const level = (0, _gameUtils.currentLevelInfo)(gameState); const level = (0, _gameUtils.currentLevelInfo)(gameState);
const hasCombo = gameState.combo > (0, _gameStateMutators.baseCombo)(gameState);
const { width, height } = gameCanvas; const { width, height } = gameCanvas;
if (!width || !height) return; if (!width || !height) return;
if (gameState.currentLevel || gameState.levelTime) menuLabel.innerText = (0, _i18N.t)("play.current_lvl", { if (gameState.currentLevel || gameState.levelTime) menuLabel.innerText = (0, _i18N.t)("play.current_lvl", {
@ -3514,7 +3515,7 @@ function render(gameState) {
ctx.globalAlpha = 1; ctx.globalAlpha = 1;
(0, _gameStateMutators.forEachLiveOne)(gameState.coins, (coin)=>{ (0, _gameStateMutators.forEachLiveOne)(gameState.coins, (coin)=>{
ctx.globalCompositeOperation = coin.color === "gold" || level.color ? "source-over" : "screen"; 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 // Black shadow around balls
if (!(0, _options.isOptionOn)("basic")) { if (!(0, _options.isOptionOn)("basic")) {
@ -3572,7 +3573,7 @@ function render(gameState) {
// The puck // The puck
ctx.globalAlpha = 1; ctx.globalAlpha = 1;
ctx.globalCompositeOperation = "source-over"; 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) { if (gameState.combo > 1) {
ctx.globalCompositeOperation = "source-over"; ctx.globalCompositeOperation = "source-over";
const comboText = "x " + gameState.combo; 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); } 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 // Borders
const hasCombo = gameState.combo > (0, _gameStateMutators.baseCombo)(gameState);
ctx.globalCompositeOperation = "source-over"; ctx.globalCompositeOperation = "source-over";
ctx.globalAlpha = gameState.perks.unbounded ? 0.1 : 1; ctx.globalAlpha = gameState.perks.unbounded ? 0.1 : 1;
if (gameState.offsetXRoundedDown) { 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.arc(size / 2, size / 2, size / 2, 0, 2 * Math.PI);
canctx.fillStyle = color; canctx.fillStyle = color;
canctx.fill(); canctx.fill();
if (color === "gold") { if (color === 'gold' || borderColor === 'red') {
canctx.strokeStyle = borderColor; canctx.strokeStyle = borderColor;
if (borderColor == 'red') {
canctx.lineWidth = 2;
canctx.setLineDash(redBorderDash);
}
canctx.stroke(); canctx.stroke();
}
if (color === "gold") {
// Fill in
canctx.beginPath(); canctx.beginPath();
canctx.arc(size / 2, size / 2, size / 2 * 0.6, 0, 2 * Math.PI); canctx.arc(size / 2, size / 2, size / 2 * 0.6, 0, 2 * Math.PI);
canctx.fillStyle = "rgba(255,255,255,0.5)"; canctx.fillStyle = "rgba(255,255,255,0.5)";

View file

@ -30,6 +30,8 @@ export const backgroundCanvas = document.createElement("canvas");
export function render(gameState: GameState) { export function render(gameState: GameState) {
const level = currentLevelInfo(gameState); const level = currentLevelInfo(gameState);
const hasCombo = gameState.combo > baseCombo(gameState);
const {width, height} = gameCanvas; const {width, height} = gameCanvas;
if (!width || !height) return; if (!width || !height) return;
@ -168,9 +170,10 @@ export function render(gameState: GameState) {
coin.size, coin.size,
coin.x, coin.x,
coin.y, coin.y,
level.color || "black", (hasCombo && gameState.perks.asceticism && 'red') || level.color || "black",
coin.a, coin.a,
); );
}); });
// Black shadow around balls // Black shadow around balls
@ -274,7 +277,7 @@ export function render(gameState: GameState) {
gameState.puckHeight, gameState.puckHeight,
0, 0,
!!gameState.perks.concave_puck, !!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) { if (gameState.combo > 1) {
@ -317,7 +320,6 @@ export function render(gameState: GameState) {
} }
} }
// Borders // Borders
const hasCombo = gameState.combo > baseCombo(gameState);
ctx.globalCompositeOperation = "source-over"; ctx.globalCompositeOperation = "source-over";
ctx.globalAlpha = gameState.perks.unbounded ? 0.1 : 1; ctx.globalAlpha = gameState.perks.unbounded ? 0.1 : 1;
@ -637,10 +639,17 @@ export function drawCoin(
canctx.fillStyle = color; canctx.fillStyle = color;
canctx.fill(); canctx.fill();
if (color === "gold") { if(color==='gold' || borderColor==='red'){
canctx.strokeStyle = borderColor; canctx.strokeStyle = borderColor;
if(borderColor=='red'){
canctx.lineWidth=2
canctx.setLineDash(redBorderDash)
}
canctx.stroke(); canctx.stroke();
}
if (color === "gold") {
// Fill in
canctx.beginPath(); canctx.beginPath();
canctx.arc(size / 2, size / 2, (size / 2) * 0.6, 0, 2 * Math.PI); canctx.arc(size / 2, size / 2, (size / 2) * 0.6, 0, 2 * Math.PI);
canctx.fillStyle = "rgba(255,255,255,0.5)"; canctx.fillStyle = "rgba(255,255,255,0.5)";