diff --git a/html/images/space.svg b/html/images/space.svg index 32a04b3..d769f17 100644 --- a/html/images/space.svg +++ b/html/images/space.svg @@ -251,14 +251,16 @@ function updateBullets(elapsed) { const deleteCount = 1; + const pt = document.querySelector('svg').createSVGPoint(); - bullets.forEach((bullet, index) => { + [...bullets].forEach((bullet, index) => { bullet.time -= elapsed; + const x = bullet.x + 0.001 * elapsed * bullet.vx; + const y = bullet.y + 0.001 * elapsed * bullet.vy; + pt.x = x; + pt.y = y; - if (bullet.time > 0) { - let y = bullet.y + 0.001 * elapsed * bullet.vy; - let x = bullet.x + 0.001 * elapsed * bullet.vx; - + if (bullet.time > 0 && !wall.isPointInFill(pt)) { [bullet.x, bullet.y] = wrapPos(x, y); bullet.node.style.transform = `translate(${bullet.x}px, ${bullet.y}px)`; } else {