fixed collision detection between bombs and player

This commit is contained in:
Joshua Perry 2022-04-29 10:52:27 +01:00
parent af9066fea9
commit 004c9755ef
1 changed files with 1 additions and 1 deletions

View File

@ -56,7 +56,7 @@ function checkExplosion() {
for (let element of document.getElementsByClassName("explosion")) { for (let element of document.getElementsByClassName("explosion")) {
var elemRect = element.getBoundingClientRect(); var elemRect = element.getBoundingClientRect();
var playerRect = document.getElementById("player").getBoundingClientRect(); var playerRect = document.getElementById("player").getBoundingClientRect();
if (elemRect.bottom >= playerRect.top && elemRect.right >= playerRect.left) { if (elemRect.bottom >= playerRect.top && elemRect.right >= playerRect.left && elemRect.left <= playerRect.right && elemRect.top <= playerRect.bottom) {
document.getElementById("player").style.display = "none"; document.getElementById("player").style.display = "none";
} }
} }