Skip to content

Commit

Permalink
Merge pull request #33 from Timur233/SOK-54_missing-bullets
Browse files Browse the repository at this point in the history
  • Loading branch information
Timur233 authored Nov 25, 2024
2 parents 4601550 + eb60f5b commit e4fa9e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/client/src/components/Game/gameLoop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ export const gameLoop = (
handleEnemyShooting(gameMap, bulletsRef)

// Обработка столкновений с препятствиями
handleBulletObstacleCollisions(bulletsRef.current, gameMap)
bulletsRef.current = handleBulletObstacleCollisions(
bulletsRef.current,
gameMap
)

initEffects(effectsRef)

Expand Down
5 changes: 4 additions & 1 deletion packages/client/src/components/Game/obstacle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -94,6 +95,8 @@ export const handleBulletObstacleCollisions = (
}
})
})

return bullets
}

const killObstacle = (
Expand Down

0 comments on commit e4fa9e1

Please sign in to comment.