diff --git a/html/images/space.svg b/html/images/space.svg
index eceed59..597e254 100644
--- a/html/images/space.svg
+++ b/html/images/space.svg
@@ -33,9 +33,9 @@
}
-
-
+
+
@@ -43,6 +43,7 @@
+
@@ -86,6 +87,7 @@
const gun = tank.querySelector('line');
const hitbox = document.querySelector(".hitbox");
const bulletsContainer = document.querySelector("#bullets");
+ const r1 = document.querySelector("#rect1");
const leftTurnButton = document.querySelector("#turn-left");
const rightTurnButton = document.querySelector("#turn-right");
@@ -242,6 +244,17 @@
if (positionX > 200) positionX += -400;
else if (positionX < -200) positionX += 400;
+ const radius = 5;
+
+ const pt = document.querySelector('svg').createSVGPoint();
+ pt.x = positionX;
+ pt.y = positionY;
+
+ if (r1.isPointInFill(pt))
+ r1.setAttribute('fill', 'red');
+ else
+ r1.setAttribute('fill', 'black');
+
hitbox.style.transform = `translate(${positionX}px, ${positionY}px)`;
// if (+y < 200)
@@ -265,7 +278,6 @@
if (!spacePressed) {
spacePressed = true;
const [x, y] = getTranslate(hitbox);
- // fireBullet(x, y);
fireBullet(x, y, velocity);
}
break;
@@ -414,7 +426,7 @@
fireButton.addEventListener("click", function (e) {
const [x, y] = getTranslate(hitbox);
- fireBullet(x, y);
+ fireBullet(x, y, velocity);
});
//]]>