From 3ed203b66293c5506c795420868b05df1b8be6d5 Mon Sep 17 00:00:00 2001 From: onezDerv Date: Fri, 4 Oct 2024 10:56:17 -0400 Subject: [PATCH] bouncy edges, crit hits --- common/player.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/common/player.js b/common/player.js index 6db06ce..d8df448 100644 --- a/common/player.js +++ b/common/player.js @@ -67,6 +67,14 @@ class Player { ent.pos.x = Math.max(Math.min(ent.pos.x, width / 2), - width / 2); ent.pos.y = Math.max(Math.min(ent.pos.y, height / 2), - height / 2); + if (Math.abs(ent.pos.x) >= width / 2 ) { + ent.vel.x = (Math.abs(ent.vel.x) + 10) * -Math.sign(ent.pos.x); + } + + if (Math.abs(ent.pos.y) >= height / 2) { + ent.vel.y = (Math.abs(ent.vel.y) + 10) * -Math.sign(ent.pos.y); + } + ent.vel.x *= 0.9; ent.vel.y *= 0.9; @@ -97,7 +105,10 @@ class Player { } if (target.immortal) continue; - target.health--; + target.health += Math.floor( (dp-0.001) * 10); + + target.vel.x += (target.pos.x - ent.pos.x) * 0.1; + target.vel.y += (target.pos.y - ent.pos.y) * 0.1; if (target.health == 0) { ent.headCount++;