mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-04-20 12:15:06 -04:00
Ball to ball explosions cleared the top left brick
This commit is contained in:
parent
60f94461e7
commit
b0c7e8decd
2 changed files with 35 additions and 30 deletions
24
dist/index.html
vendored
24
dist/index.html
vendored
|
@ -2489,18 +2489,20 @@ 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];
|
|
||||||
schedulGameSound(gameState, "explode", ball.x, 1);
|
|
||||||
const col = index % gameState.gridSize;
|
|
||||||
const row = Math.floor(index / gameState.gridSize);
|
|
||||||
const size = 1 + gameState.perks.bigger_explosions;
|
const size = 1 + gameState.perks.bigger_explosions;
|
||||||
// Break bricks around
|
schedulGameSound(gameState, "explode", ball.x, 1);
|
||||||
for(let dx = -size; dx <= size; dx++)for(let dy = -size; dy <= size; dy++){
|
if (index !== -1) {
|
||||||
const i = (0, _gameUtils.getRowColIndex)(gameState, row + dy, col + dx);
|
if (gameState.bricks[index] == "black") delete gameState.bricks[index];
|
||||||
if (gameState.bricks[i] && i !== -1) {
|
const col = index % gameState.gridSize;
|
||||||
// Study bricks resist explosions too
|
const row = Math.floor(index / gameState.gridSize);
|
||||||
if (gameState.bricks[i] !== "black" && gameState.perks.sturdy_bricks > Math.random() * 5) continue;
|
// Break bricks around
|
||||||
explodeBrick(gameState, i, ball, true);
|
for(let dx = -size; dx <= size; dx++)for(let dy = -size; dy <= size; dy++){
|
||||||
|
const i = (0, _gameUtils.getRowColIndex)(gameState, row + dy, col + dx);
|
||||||
|
if (gameState.bricks[i] && i !== -1) {
|
||||||
|
// Study bricks resist explosions too
|
||||||
|
if (gameState.bricks[i] !== "black" && gameState.perks.sturdy_bricks > Math.random() * 5) continue;
|
||||||
|
explodeBrick(gameState, i, ball, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Blow nearby coins
|
// Blow nearby coins
|
||||||
|
|
|
@ -251,29 +251,33 @@ export function explosionAt(
|
||||||
y: number,
|
y: number,
|
||||||
ball: Ball,
|
ball: 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){
|
||||||
|
|
||||||
const col = index % gameState.gridSize;
|
if (gameState.bricks[index] == "black") delete gameState.bricks[index];
|
||||||
const row = Math.floor(index / gameState.gridSize);
|
|
||||||
const size = 1 + gameState.perks.bigger_explosions;
|
|
||||||
// Break bricks around
|
const col = index % gameState.gridSize;
|
||||||
for (let dx = -size; dx <= size; dx++) {
|
const row = Math.floor(index / gameState.gridSize);
|
||||||
for (let dy = -size; dy <= size; dy++) {
|
// Break bricks around
|
||||||
const i = getRowColIndex(gameState, row + dy, col + dx);
|
for (let dx = -size; dx <= size; dx++) {
|
||||||
if (gameState.bricks[i] && i !== -1) {
|
for (let dy = -size; dy <= size; dy++) {
|
||||||
// Study bricks resist explosions too
|
const i = getRowColIndex(gameState, row + dy, col + dx);
|
||||||
if (
|
if (gameState.bricks[i] && i !== -1) {
|
||||||
gameState.bricks[i] !== "black" &&
|
// Study bricks resist explosions too
|
||||||
gameState.perks.sturdy_bricks > Math.random() * 5
|
if (
|
||||||
)
|
gameState.bricks[i] !== "black" &&
|
||||||
continue;
|
gameState.perks.sturdy_bricks > Math.random() * 5
|
||||||
explodeBrick(gameState, i, ball, true);
|
)
|
||||||
|
continue;
|
||||||
|
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;
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue