From 75f0073b470a6afa0634fb2e60cbee20dda8181d Mon Sep 17 00:00:00 2001 From: Raymond Xu <2rayxu+github@gmail.com> Date: Mon, 18 Jan 2021 19:35:37 -0600 Subject: [PATCH] Fix laser cooldown bug --- 6-space-game/4-collision-detection/solution/app.js | 5 +++-- 6-space-game/5-keeping-score/solution/app.js | 5 +++-- 6-space-game/5-keeping-score/your-work/app.js | 5 +++-- 6-space-game/6-end-condition/solution/app.js | 5 +++-- 6-space-game/6-end-condition/your-work/app.js | 5 +++-- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/6-space-game/4-collision-detection/solution/app.js b/6-space-game/4-collision-detection/solution/app.js index 2fe85994..30030312 100644 --- a/6-space-game/4-collision-detection/solution/app.js +++ b/6-space-game/4-collision-detection/solution/app.js @@ -60,8 +60,9 @@ class Hero extends GameObject { let id = setInterval(() => { if (this.cooldown > 0) { this.cooldown -= 100; - } else { - clearInterval(id); + if(this.cooldown === 0) { + clearInterval(id); + } } }, 200); } diff --git a/6-space-game/5-keeping-score/solution/app.js b/6-space-game/5-keeping-score/solution/app.js index 87978a91..59eb7d6d 100644 --- a/6-space-game/5-keeping-score/solution/app.js +++ b/6-space-game/5-keeping-score/solution/app.js @@ -60,8 +60,9 @@ class Hero extends GameObject { let id = setInterval(() => { if (this.cooldown > 0) { this.cooldown -= 100; - } else { - clearInterval(id); + if(this.cooldown === 0) { + clearInterval(id); + } } }, 200); } diff --git a/6-space-game/5-keeping-score/your-work/app.js b/6-space-game/5-keeping-score/your-work/app.js index 8f01eef9..2bd9e5ac 100644 --- a/6-space-game/5-keeping-score/your-work/app.js +++ b/6-space-game/5-keeping-score/your-work/app.js @@ -58,8 +58,9 @@ class Hero extends GameObject { let id = setInterval(() => { if (this.cooldown > 0) { this.cooldown -= 100; - } else { - clearInterval(id); + if(this.cooldown === 0) { + clearInterval(id); + } } }, 200); } diff --git a/6-space-game/6-end-condition/solution/app.js b/6-space-game/6-end-condition/solution/app.js index f16f290c..9004f5ba 100644 --- a/6-space-game/6-end-condition/solution/app.js +++ b/6-space-game/6-end-condition/solution/app.js @@ -65,8 +65,9 @@ class Hero extends GameObject { let id = setInterval(() => { if (this.cooldown > 0) { this.cooldown -= 100; - } else { - clearInterval(id); + if(this.cooldown === 0) { + clearInterval(id); + } } }, 200); } diff --git a/6-space-game/6-end-condition/your-work/app.js b/6-space-game/6-end-condition/your-work/app.js index abad8476..e8023401 100644 --- a/6-space-game/6-end-condition/your-work/app.js +++ b/6-space-game/6-end-condition/your-work/app.js @@ -60,8 +60,9 @@ class Hero extends GameObject { let id = setInterval(() => { if (this.cooldown > 0) { this.cooldown -= 100; - } else { - clearInterval(id); + if(this.cooldown === 0) { + clearInterval(id); + } } }, 200); }