Skip to content

Commit

Permalink
feat: kill player if outside of level
Browse files Browse the repository at this point in the history
  • Loading branch information
Stan-Stani committed Jan 27, 2024
1 parent 8b1bfd6 commit 196b285
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/games/bobber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,23 @@ export class BobberScene extends Scene {
this.#playerOne?.body?.acceleration
)
stickyMessage('brakingInfo:', this.#playerOne?.brakingInfo)
if (!this.#playerOne) return
if (!this.#playerOne || !this.#spawnPlayer) return

const nullIfOutsideLevel = this.#water?.getTileAtWorldXY(
this.#playerOne.body.x + this.#playerOne.body.width / 2,
this.#playerOne.body.y + this.#playerOne.body.height / 2,
true
)

if (nullIfOutsideLevel === null) {
this.#playerOne?.setPosition(
this.#spawnPlayer[0].x,
this.#spawnPlayer[0].y - 50
)
this.#playerOne?.setVelocity(0, 0)
}



// Don't waste time calculating super small velocity endlessly for drag
if (
Expand Down

0 comments on commit 196b285

Please sign in to comment.