Skip to content

Commit

Permalink
Players now die when they fall off
Browse files Browse the repository at this point in the history
  • Loading branch information
Melchizedek6809 committed Jan 20, 2025
1 parent 86ed985 commit 77ca3d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/world/entity/being.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@ export abstract class Being extends Entity {
Math.min(this.health - rawAmount, this.maxHealth),
);
if (this.health <= 0) {
this.isDead = true;
this.onDeath();
this.die();
}
}

die() {
this.isDead = true;
this.onDeath();
}

heal(rawAmount: number): void {
this.damage(-rawAmount);
}
Expand Down
4 changes: 4 additions & 0 deletions src/world/entity/character.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ export class Character extends Being {
return;
}

if (this.y < 800) {
this.die();
}

if (this.noClip) {
this.vx = this.vy = this.vz = 0;
this.x += this.movementX;
Expand Down

0 comments on commit 77ca3d9

Please sign in to comment.