Bien sûr, voici une version possible de l'animation d'explosion pour votre jeu :JavaScript:function detectCollision() { function barilsSetups() { for (var baril in explosive) { if (explosive[baril].currentState != 3) { if (!explosive.hasOwnProperty(baril)) continue; for (var i = 0; i < bullets.length; i++) { var bullet = bullets[i]; if (explosive[baril].currentState == 1) { if (bullet.x >= explosive[baril].posx - player.posx && bullet.x < explosive[baril].posx + explosive[baril].width - player.posx && bullet.y >= explosive[baril].posy - player.posy && bullet.y < explosive[baril].posy + explosive[baril].height - player.posy) { explosive[baril].heal -= player.damages; bullets.splice(i, 1); i--; } } if (explosive[baril].heal <= 0) { let barilBackup = baril explosive[barilBackup].currentState = 2; // Animation ici. setTimeout(() => { explosive[barilBackup].image.src = ""; explosive[barilBackup].currentState = 3; }, 1000); } } } } } barilsSetups(); }
Fais-moi une animation d'explosion stp
JavaScript:
function detectCollision() {
function barilsSetups() {
for (var baril in explosive) {
if (explosive[baril].currentState !=