mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-04-21 04:26:14 -04:00
Build 29041682
This commit is contained in:
parent
3eca148fb8
commit
760fa5715b
16 changed files with 289 additions and 152 deletions
|
@ -148,3 +148,26 @@ export function shouldPierceByColor(
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export function countBricksAbove(gameState: GameState, index: number) {
|
||||
const col = index % gameState.gridSize;
|
||||
const row = Math.floor(index / gameState.gridSize);
|
||||
let count = 0;
|
||||
for (let y = 0; y < row; y++) {
|
||||
if (gameState.bricks[col + y * gameState.gridSize]) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
export function countBricksBelow(gameState: GameState, index: number) {
|
||||
const col = index % gameState.gridSize;
|
||||
const row = Math.floor(index / gameState.gridSize);
|
||||
let count = 0;
|
||||
for (let y = row + 1; y < gameState.gridSize; y++) {
|
||||
if (gameState.bricks[col + y * gameState.gridSize]) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue