From 629a5c3f227778ef9e9cdb7a0581885a461722c0 Mon Sep 17 00:00:00 2001 From: iskandarov Date: Mon, 28 Oct 2024 02:09:06 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=88=D0=B5=D0=BB=20=D0=B8=20?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D0=BD=D1=83=D0=BB=20=D0=BD=D0=B0=20=D0=BC?= =?UTF-8?q?=D0=B5=D1=81=D1=82=D0=BE=20=D1=83=D1=82=D0=B5=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=BD=D1=8B=D0=B5=20=D0=BF=D1=83=D0=BB=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/src/components/Game/gameLoop.tsx | 5 ++- .../client/src/components/Game/obstacle.tsx | 32 +++---------------- 2 files changed, 8 insertions(+), 29 deletions(-) diff --git a/packages/client/src/components/Game/gameLoop.tsx b/packages/client/src/components/Game/gameLoop.tsx index 75904a5..40ad7ec 100644 --- a/packages/client/src/components/Game/gameLoop.tsx +++ b/packages/client/src/components/Game/gameLoop.tsx @@ -69,7 +69,10 @@ export const gameLoop = ( handleEnemyShooting(enemiesRef.current, bulletsRef) // Обработка столкновений с препятствиями - handleBulletObstacleCollisions(bulletsRef.current, obstaclesRef.current) + bulletsRef.current = handleBulletObstacleCollisions( + bulletsRef.current, + obstaclesRef.current + ) initEffects(effectsRef) diff --git a/packages/client/src/components/Game/obstacle.tsx b/packages/client/src/components/Game/obstacle.tsx index 64314ab..a32fe42 100644 --- a/packages/client/src/components/Game/obstacle.tsx +++ b/packages/client/src/components/Game/obstacle.tsx @@ -81,33 +81,6 @@ export const initializeCompanyMapObstacle = (): Obstacle[] => { { type: Types.Tree, x: 0, y: 504, width: 180, height: 72 }, { type: Types.Tree, x: 612, y: 504, width: 180, height: 72 }, ]) - return createMap([ - // /{ type: Types.Steel, x: 0, y: 0, width: 120, height: 50 }, - { type: Types.Steel, x: 200, y: 0, width: 70, height: 36 }, - { type: Types.Steel, x: 350, y: 0, width: 70, height: 36 }, - { type: Types.Steel, x: 500, y: 0, width: 120, height: 36 }, - // { type: Types.Wall, x: 700, y: 0, width: 100, height: 50 }, - - // { type: Types.Wall, x: 0, y: 130, width: 50, height: 120 }, - { type: Types.Wall, x: 130, y: 130, width: 50, height: 70 }, - // { type: Types.Wall, x: 260, y: 130, width: 50, height: 200 }, - { type: Types.Wall, x: 390, y: 130, width: 50, height: 70 }, - { type: Types.Wall, x: 520, y: 130, width: 50, height: 120 }, - // { type: Types.Wall, x: 650, y: 130, width: 50, height: 125 }, - - // { type: Types.Wall, x: 0, y: 330, width: 120, height: 50 }, - { type: Types.Wall, x: 200, y: 330, width: 150, height: 36 }, - { type: Types.Wall, x: 350, y: 330, width: 70, height: 36 }, - { type: Types.Wall, x: 500, y: 330, width: 120, height: 36 }, - // { type: Types.Wall, x: 700, y: 330, width: 100, height: 100 }, - - { type: Types.Wall, x: 0, y: 460, width: 50, height: 140 }, - { type: Types.Wall, x: 130, y: 530, width: 50, height: 70 }, - { type: Types.Wall, x: 260, y: 480, width: 50, height: 120 }, - //{ type: Types.Wall, x: 390, y: 460, width: 50, height: 70 }, - { type: Types.Wall, x: 520, y: 490, width: 50, height: 120 }, - { type: Types.Wall, x: 650, y: 480, width: 50, height: 120 }, - ]) } export const createMap = ( @@ -201,7 +174,8 @@ export const handleBulletObstacleCollisions = ( 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 @@ -210,6 +184,8 @@ export const handleBulletObstacleCollisions = ( } }) }) + + return bullets } const killObstacle = (obstacles: Obstacle[], obstacle: Obstacle) => {