diff --git a/packages/client/src/components/Game/gameLoop.tsx b/packages/client/src/components/Game/gameLoop.tsx index 0ffae70..c52ae70 100644 --- a/packages/client/src/components/Game/gameLoop.tsx +++ b/packages/client/src/components/Game/gameLoop.tsx @@ -88,7 +88,10 @@ export const gameLoop = ( handleEnemyShooting(gameMap, bulletsRef) // Обработка столкновений с препятствиями - handleBulletObstacleCollisions(bulletsRef.current, gameMap) + bulletsRef.current = handleBulletObstacleCollisions( + bulletsRef.current, + gameMap + ) initEffects(effectsRef) diff --git a/packages/client/src/components/Game/obstacle.tsx b/packages/client/src/components/Game/obstacle.tsx index 128ce58..8f53ba5 100644 --- a/packages/client/src/components/Game/obstacle.tsx +++ b/packages/client/src/components/Game/obstacle.tsx @@ -85,7 +85,8 @@ export const handleBulletObstacleCollisions = ( gameMap.current.obstacles.forEach(obstacle => { if (detectCollision(bullet, obstacle)) { // Логика для уничтожения пули, если она попала в препятствие - bullets.splice(bullets.indexOf(bullet), 1) // Пример, удаляем пулю, если попала в препятствие + + bullets = bullets.filter(i => i !== bullet) createBangEffect( bullet.x + bullet.width / 2, bullet.y + bullet.height / 2 @@ -94,6 +95,8 @@ export const handleBulletObstacleCollisions = ( } }) }) + + return bullets } const killObstacle = (