From 5ad54b663373753c8fead033b6b06f9eeee7d735 Mon Sep 17 00:00:00 2001 From: vuillaume Date: Mon, 8 Jul 2024 19:37:30 +0200 Subject: [PATCH] bug --- Site/Js/JsGame/heart.js | 20 +++++++++++--------- Site/Js/JsGame/play.js | 3 +-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Site/Js/JsGame/heart.js b/Site/Js/JsGame/heart.js index 43bbb89..570bc2f 100644 --- a/Site/Js/JsGame/heart.js +++ b/Site/Js/JsGame/heart.js @@ -15,6 +15,13 @@ let heart = heartMax; let invincible = false +function invincibleMan(timeInvincible) { + invincible = true; + setTimeout(function() { + invincible = false; + }, timeInvincible); +} + function heartChange(heartLess) { if (invincible) { @@ -35,12 +42,10 @@ function heartChange(heartLess) { soundDamage.play(); } - if(heart ==! 0) { - invincible = true; - setTimeout(function() { - invincible = false; - }, 2500); + if(heart > 0) { + invincibleMan(2500); } + } else { heart += heartLess; @@ -76,10 +81,7 @@ reprendreDied.onclick = function() { body.style.cursor = "none"; menuKeys = false; - invincible = true; - setTimeout(function() { - invincible = false; - }, 2500); + invincibleMan(2500); if(!diedReprendre) { heart = heartMax; diff --git a/Site/Js/JsGame/play.js b/Site/Js/JsGame/play.js index fc0bd35..adb3746 100644 --- a/Site/Js/JsGame/play.js +++ b/Site/Js/JsGame/play.js @@ -675,11 +675,10 @@ window.addEventListener("keydown", function(e) { if(!menuKeys){ if(PotionSpeed > 0 && playerSpeed === 2) { playerSpeed = 3; - invincible = true; setTimeout(function() { playerSpeed = 2; - invincible = false; }, 10000); + invincibleMan(10000); potionSpeedChange(-1); } }