when players die, they should acutally fucking die

This commit is contained in:
Freya Murphy 2023-06-29 20:29:54 -04:00
parent 504a7669bf
commit c66865d431
4 changed files with 25 additions and 7 deletions

View file

@ -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
}

View file

@ -44,7 +44,7 @@ export const updateItems = (data: GameState) => {
const player = data.players[id]
if(!player) {
if(!player || player.dead) {
continue;
}

View file

@ -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--
}

View file

@ -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) => {