mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-04-21 20:46:14 -04:00
Build 29071900
This commit is contained in:
parent
4bb5d820c5
commit
1b94bcd6be
16 changed files with 526 additions and 143 deletions
|
@ -81,6 +81,22 @@ export function getRowColIndex(gameState: GameState, row: number, col: number) {
|
|||
return row * gameState.gridSize + col;
|
||||
}
|
||||
|
||||
export function getClosestBall(
|
||||
gameState: GameState,
|
||||
x: number,
|
||||
y: number,
|
||||
): Ball | null {
|
||||
let closestBall: Ball | null = null;
|
||||
let dist = 0;
|
||||
gameState.balls.forEach((ball) => {
|
||||
const d2 = (ball.x - x) * (ball.x - x) + (ball.y - y) * (ball.y - y);
|
||||
if (d2 < dist || !closestBall) {
|
||||
closestBall = ball;
|
||||
dist = d2;
|
||||
}
|
||||
});
|
||||
return closestBall;
|
||||
}
|
||||
export function getPossibleUpgrades(gameState: GameState) {
|
||||
return upgrades
|
||||
.filter((u) => getTotalScore() >= u.threshold)
|
||||
|
@ -375,9 +391,10 @@ export function reasonLevelIsLocked(
|
|||
}
|
||||
|
||||
export function ballTransparency(ball: Ball, gameState: GameState) {
|
||||
if (!gameState.perks.transparency) return 0;
|
||||
return clamp(
|
||||
gameState.perks.transparency * (1 - ball.y / gameState.gameZoneHeight) -
|
||||
0.2,
|
||||
gameState.perks.transparency *
|
||||
(1 - (ball.y / gameState.gameZoneHeight) * 1.2),
|
||||
0,
|
||||
1,
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue