Ball to ball explosions cleared the top left brick

This commit is contained in:
Renan LE CARO 2025-03-22 16:58:35 +01:00
parent 60f94461e7
commit b0c7e8decd
2 changed files with 35 additions and 30 deletions

6
dist/index.html vendored
View file

@ -2489,11 +2489,12 @@ function spawnExplosion(gameState, count, x, y, color) {
for(let i = 0; i < count; i++)makeParticle(gameState, x + (Math.random() - 0.5) * gameState.brickWidth / 2, y + (Math.random() - 0.5) * gameState.brickWidth / 2, (Math.random() - 0.5) * 30, (Math.random() - 0.5) * 30, color, false); for(let i = 0; i < count; i++)makeParticle(gameState, x + (Math.random() - 0.5) * gameState.brickWidth / 2, y + (Math.random() - 0.5) * gameState.brickWidth / 2, (Math.random() - 0.5) * 30, (Math.random() - 0.5) * 30, color, false);
} }
function explosionAt(gameState, index, x, y, ball) { function explosionAt(gameState, index, x, y, ball) {
if (gameState.bricks[index] == "black") delete gameState.bricks[index]; const size = 1 + gameState.perks.bigger_explosions;
schedulGameSound(gameState, "explode", ball.x, 1); schedulGameSound(gameState, "explode", ball.x, 1);
if (index !== -1) {
if (gameState.bricks[index] == "black") delete gameState.bricks[index];
const col = index % gameState.gridSize; const col = index % gameState.gridSize;
const row = Math.floor(index / gameState.gridSize); const row = Math.floor(index / gameState.gridSize);
const size = 1 + gameState.perks.bigger_explosions;
// Break bricks around // Break bricks around
for(let dx = -size; dx <= size; dx++)for(let dy = -size; dy <= size; dy++){ for(let dx = -size; dx <= size; dx++)for(let dy = -size; dy <= size; dy++){
const i = (0, _gameUtils.getRowColIndex)(gameState, row + dy, col + dx); const i = (0, _gameUtils.getRowColIndex)(gameState, row + dy, col + dx);
@ -2503,6 +2504,7 @@ function explosionAt(gameState, index, x, y, ball) {
explodeBrick(gameState, i, ball, true); explodeBrick(gameState, i, ball, true);
} }
} }
}
// Blow nearby coins // Blow nearby coins
forEachLiveOne(gameState.coins, (c)=>{ forEachLiveOne(gameState.coins, (c)=>{
const dx = c.x - x; const dx = c.x - x;

View file

@ -251,13 +251,16 @@ export function explosionAt(
y: number, y: number,
ball: Ball, ball: Ball,
) { ) {
const size = 1 + gameState.perks.bigger_explosions;
schedulGameSound(gameState, "explode", ball.x, 1);
if(index!==-1){
if (gameState.bricks[index] == "black") delete gameState.bricks[index]; if (gameState.bricks[index] == "black") delete gameState.bricks[index];
schedulGameSound(gameState, "explode", ball.x, 1);
const col = index % gameState.gridSize; const col = index % gameState.gridSize;
const row = Math.floor(index / gameState.gridSize); const row = Math.floor(index / gameState.gridSize);
const size = 1 + gameState.perks.bigger_explosions;
// Break bricks around // Break bricks around
for (let dx = -size; dx <= size; dx++) { for (let dx = -size; dx <= size; dx++) {
for (let dy = -size; dy <= size; dy++) { for (let dy = -size; dy <= size; dy++) {
@ -274,6 +277,7 @@ export function explosionAt(
} }
} }
}
// Blow nearby coins // Blow nearby coins
forEachLiveOne(gameState.coins, (c) => { forEachLiveOne(gameState.coins, (c) => {
const dx = c.x - x; const dx = c.x - x;
@ -998,7 +1002,6 @@ export function gameStateTick(
((Math.random() - 0.5) * limit) / 3; ((Math.random() - 0.5) * limit) / 3;
let index = brickIndex(x, y); let index = brickIndex(x, y);
explosionAt(gameState, index, x, y, a); explosionAt(gameState, index, x, y, a);
} }
}), }),