Skip to content

Commit 62e330a

Browse files
authored
Refactor heart lifespan and explosion handling
Updated the lifespan calculation for the heart element and modified the explosion logic to ensure the heart is removed after the explosion.
1 parent f37b882 commit 62e330a

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

index.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -433,22 +433,22 @@ <h2 class="erros-titulo">Erros & Bugs</h2>
433433

434434
document.body.appendChild(coracao);
435435

436-
const tempoVida = duracaoMs * (Math.random() * 0.08 + 0.08);
436+
const tempoVida = duracaoMs * (Math.random() * 0.7 + 0.3);
437437

438438
setTimeout(() => {
439439
const rect = coracao.getBoundingClientRect();
440440
const x = rect.left + size / 2;
441441
const y = rect.top + size / 2;
442442
const sorteio = Math.random();
443443

444-
if (y > 0 && y < window.innerHeight) {
445-
if (sorteio < 0.5) {
446-
origemExplosaoPop(x, y);
447-
} else {
448-
criarExplosaoFumaca(x, y);
449-
}
444+
if (sorteio < 0.5) {
445+
origemExplosaoPop(x, y);
446+
coracao.remove();
447+
448+
} else {
449+
criarExplosaoFumaca(x, y);
450+
coracao.remove();
450451
}
451-
coracao.remove();
452452
}, tempoVida);
453453
}
454454

0 commit comments

Comments
 (0)