Red border dashes

This commit is contained in:
Renan LE CARO 2025-03-25 08:22:58 +01:00
parent 83d335b05e
commit 80dd1f0758
11 changed files with 1011 additions and 931 deletions

View file

@ -53,9 +53,6 @@ import { use } from "react";
export function setMousePos(gameState: GameState, x: number) {
// Sets the puck position, and updates the ball position if they are supposed to follow it
if (Math.abs(x - gameState.puckPosition) > 1) {
gameState.lastPuckMove = gameState.levelTime;
}
gameState.puckPosition = x;
gameState.needsRender = true;
}
@ -165,6 +162,11 @@ export function normalizeGameState(gameState: GameState) {
if (gameState.ballStickToPuck) {
putBallsAtPuck(gameState);
}
if (Math.abs(gameState.lastPuckPosition - gameState.puckPosition) > 1 && gameState.running) {
gameState.lastPuckMove = gameState.levelTime;
}
gameState.lastPuckPosition = gameState.puckPosition
}
export function baseCombo(gameState: GameState) {
@ -431,7 +433,7 @@ export function explodeBrick(
gameState.lastPuckMove &&
gameState.perks.passive_income &&
gameState.lastPuckMove >
gameState.levelTime - 500 * gameState.perks.passive_income
gameState.levelTime - 250 * gameState.perks.passive_income
) {
resetCombo(gameState, x, y);
}
@ -845,6 +847,7 @@ export function gameStateTick(
gameState.combo,
);
gameState.balls = gameState.balls.filter((ball) => !ball.destroyed);
const remainingBricks = gameState.bricks.filter(

View file

@ -61,7 +61,7 @@ export function pickedUpgradesHTMl(gameState: GameState) {
let list = "";
for (let u of upgrades) {
for (let i = 0; i < gameState.perks[u.id]; i++)
list += icons["icon:" + u.id] + " ";
list += `<span title="${u.name}">${icons["icon:" + u.id]}</span>`;
}
return list;
}
@ -69,7 +69,7 @@ export function levelsListHTMl(gameState: GameState) {
if (!gameState.perks.clairvoyant) return "";
let list = "";
for (let i = 0; i < max_levels(gameState); i++) {
list += `<span style="opacity: ${i >= gameState.currentLevel ? 1 : 0.2}">${icons[gameState.runLevels[i].name]}</span>`;
list += `<span style="opacity: ${i >= gameState.currentLevel ? 1 : 0.2}" title="${gameState.runLevels[i].name}">${icons[gameState.runLevels[i].name]}</span>`;
}
return `<p>${t("score_panel.upcoming_levels")}</p><p>${list}</p>`;
}
@ -179,4 +179,4 @@ export function countBricksBelow(gameState: GameState, index: number) {
}
}
return count;
}
}

View file

@ -41,6 +41,7 @@ export function newGameState(params: RunParams): GameState {
isGameOver: false,
ballStickToPuck: true,
puckPosition: 400,
lastPuckPosition: 400,
pauseTimeout: null,
canvasWidth: 0,
canvasHeight: 0,

File diff suppressed because it is too large Load diff

1
src/types.d.ts vendored
View file

@ -206,6 +206,7 @@ export type GameState = {
needsRender: boolean;
// Position of the center of the puck on the canvas in pixels, from the left of the canvas.
puckPosition: number;
lastPuckPosition: number;
// Will be set if the game is about to be paused. Game pause is delayed by a few milliseconds if you pause a few times in a run,
// to avoid abuse of the "release to pause" feature on mobile.
pauseTimeout: NodeJS.Timeout | null;

View file

@ -573,7 +573,7 @@ export const rawUpgrades = [
max: 4,
name: t("upgrades.passive_income.name"),
help: (lvl: number) =>
t("upgrades.passive_income.help", { time: lvl / 2, lvl }),
t("upgrades.passive_income.help", { time: lvl * 0.25, lvl }),
fullHelp: t("upgrades.passive_income.fullHelp"),
},
{