From c66865d431532330194f6b845160e01a7ba003ab Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Thu, 29 Jun 2023 20:29:54 -0400 Subject: [PATCH] when players die, they should acutally fucking die --- client/src/logic/ai.ts | 13 ++++++++++++- client/src/logic/items.ts | 2 +- client/src/logic/movement.ts | 9 +++++++++ client/src/main.ts | 8 +++----- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/client/src/logic/ai.ts b/client/src/logic/ai.ts index 25e5d25..26f9aed 100644 --- a/client/src/logic/ai.ts +++ b/client/src/logic/ai.ts @@ -96,7 +96,10 @@ const getNearestPlayer = (state: GameState, pos: Vec2): Player => { let nearest = undefined; for (let id in state.players) { let player = state.players[id]; - if (!id) continue; + + if (!player || player.dead) { + continue + } let d = dist(player.pos, pos) if (!min || min > d) { @@ -176,6 +179,10 @@ const checkIfEaten = (ghost: Ghost, state: GameState): boolean => { for (let id in state.players) { let player = state.players[id] + if (!player || player.dead) { + continue + } + if (player.thiccLeft > 0 && dist(player.pos, ghost.pos) <= 1) { return true } @@ -193,6 +200,10 @@ const updateKilled = (ghost: Ghost, state: GameState) => { for (let id in state.players) { let player = state.players[id] + if (!player || player.dead) { + continue + } + if (dist(player.pos, ghost.pos) > 1) { continue } diff --git a/client/src/logic/items.ts b/client/src/logic/items.ts index 79624d3..1803508 100644 --- a/client/src/logic/items.ts +++ b/client/src/logic/items.ts @@ -44,7 +44,7 @@ export const updateItems = (data: GameState) => { const player = data.players[id] - if(!player) { + if(!player || player.dead) { continue; } diff --git a/client/src/logic/movement.ts b/client/src/logic/movement.ts index 726f87a..32956f9 100644 --- a/client/src/logic/movement.ts +++ b/client/src/logic/movement.ts @@ -193,6 +193,11 @@ const updateCollision = (data: GameState) => { for (let i = 0; i < num - 1; i++) { for (let j = i + 1; j < num; j++) { + + if (players[i].dead || players[j].dead) { + continue + } + let rot = checkBoundingBox(bb[i], bb[j]) if (rot == Rotation.NOTHING) { continue @@ -224,6 +229,10 @@ export const updateMovement = (data: GameState) => { const player = data.players[id] + if (!player || player.dead) { + continue + } + if (player.thiccLeft > 0) { player.thiccLeft-- } diff --git a/client/src/main.ts b/client/src/main.ts index af985db..8e69037 100644 --- a/client/src/main.ts +++ b/client/src/main.ts @@ -49,8 +49,6 @@ mapeditor.onclick = function() { window.location.href = 'mapeditor.html' } -const updateGraphics = startGraphicsUpdater() - const onLoad = (startData: Frame) => { if (startData.data.started) { @@ -71,10 +69,10 @@ const onLoad = (startData: Frame) => { return true } -const onFrame = (data: Frame, frame: number) => { - - updateGraphics(data ? data.data : InitialState, frame); +const updateGraphics = startGraphicsUpdater() +const onFrame = (data: Frame, frame: number) => { + updateGraphics(data ? data.data : InitialState, frame); } const startGame = (code: string, name: string) => {